fix(mail): properly sort partial fetch results (modseq)

Fixes #5385
pull/273/merge
Francis Lachapelle 2021-09-08 16:54:42 -04:00
parent 2a8d64d891
commit 534bea674b
1 changed files with 21 additions and 0 deletions

View File

@ -100,6 +100,22 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
return [modseq1 compare: modseq2];
}
static NSComparisonResult _compareFetchResultsByUID (id entry1, id entry2, NSArray *uids)
{
NSString *uid1, *uid2;
NSUInteger pos1, pos2;
uid1 = [entry1 objectForKey: @"uid"];
uid2 = [entry2 objectForKey: @"uid"];
pos1 = [uids indexOfObject: uid1];
pos2 = [uids indexOfObject: uid2];
if (pos1 > pos2)
return NSOrderedDescending;
else
return NSOrderedAscending;
}
@interface NGImap4Connection (PrivateMethods)
- (NSString *) imap4FolderNameForURL: (NSURL *) url;
@ -2344,6 +2360,11 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
fetchResults = [fetchResults sortedArrayUsingFunction: _compareFetchResultsByMODSEQ
context: NULL];
}
else
{
fetchResults = [fetchResults sortedArrayUsingFunction: (int(*)(id, id, void*))_compareFetchResultsByUID
context: uids];
}
for (i = 0; i < [fetchResults count]; i++)
{