mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-09 08:53:20 +00:00
(mail) Fix JSON representation of mail threads
This commit is contained in:
@@ -478,11 +478,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];
|
||||
@@ -492,6 +489,7 @@
|
||||
if (![thread respondsToSelector: @selector(objectEnumerator)])
|
||||
return nil;
|
||||
|
||||
count = 0;
|
||||
first = [thread count] > 1;
|
||||
thread = [thread objectEnumerator];
|
||||
|
||||
@@ -510,22 +508,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)
|
||||
{
|
||||
@@ -548,14 +544,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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user