(mail) Fix JSON representation of mail threads

pull/257/head
Francis Lachapelle 2019-06-20 11:51:07 -04:00
parent d3ce8a8d2e
commit fd38816a8c
1 changed files with 9 additions and 12 deletions

View File

@ -513,11 +513,8 @@
int i;
BOOL first;
BOOL expected;
int previousLevel;
count = 0;
i = 0;
previousLevel = 0;
expected = YES;
threads = [NSMutableArray arrayWithObject: [NSArray arrayWithObjects: @"uid", @"level", @"first", nil]];
rootThreads = [_sortedUIDs objectEnumerator];
@ -527,6 +524,7 @@
if (![thread respondsToSelector: @selector(objectEnumerator)])
return nil;
count = 0;
first = [thread count] > 1;
thread = [thread objectEnumerator];
@ -545,22 +543,20 @@
t = thread; // never happen?
while (t && ![t isKindOfClass: [NSArray class]])
{
BOOL currentFirst;
int currentLevel;
int level;
NSArray *currentThread;
currentFirst = (first && ecount == 0) || (i == 0 && count > 0) || (count > 0 && previousLevel < 0);
currentLevel = (first && ecount == 0) ? 0 : (count > 0 ? count : -1);
level = first? 0 : (count > 0? count : -1);
currentThread = [NSArray arrayWithObjects: t,
[NSNumber numberWithInt: currentLevel],
[NSNumber numberWithInt: currentFirst], nil];
[NSNumber numberWithInt: level],
[NSNumber numberWithInt: first], nil];
[threads addObject: currentThread];
i++;
count++;
ecount++;
expected = NO;
previousLevel = currentLevel;
t = [thread nextObject];
first = 0;
}
if (t)
{
@ -583,14 +579,15 @@
}
else
{
thread = [[rootThreads nextObject] objectEnumerator]; // assume all objects of rootThreads are NSArrays
thread = [rootThreads nextObject];
count = 0;
first = [thread count] > 1;
thread = [thread objectEnumerator];
expected = YES;
}
// Prepare next iteration
thread = [thread allObjects];
first = !first && (thread != nil) && [thread count] > 1;
thread = [thread objectEnumerator];
}