Skip to content

Commit b002282

Browse files
committed
Fix folders missed by "Refresh All Subscriptions"
We have to improve discrepancies detection between local and remote as "unread-count" requests only report folders having some unread articles. Cherry-pick of commit 1a652cd
1 parent 1306be1 commit b002282

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Vienna/Sources/Fetching/OpenReader.m

+10
Original file line numberDiff line numberDiff line change
@@ -970,11 +970,13 @@ -(void)unreadCountDone:(NSMutableURLRequest *)request response:(NSURLResponse *)
970970
NSDictionary *unreadDict;
971971
NSError *jsonError;
972972
unreadDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
973+
NSMutableArray *remoteUnreadFeeds = [NSMutableArray array];
973974
for (NSDictionary *feed in unreadDict[@"unreadcounts"]) {
974975
NSString *feedID = feed[@"id"];
975976
if ([feedID hasPrefix:@"feed/"]) {
976977
Folder *folder = [[Database sharedManager] folderFromRemoteId:feedID];
977978
if (folder) {
979+
[remoteUnreadFeeds addObject:feedID];
978980
NSInteger remoteCount = ((NSString *)feed[@"count"]).intValue;
979981
NSInteger localCount = folder.unreadCount;
980982
NSInteger remoteTimestamp = ((NSString *)feed[@"newestItemTimestampUsec"]).longLongValue / 1000000; // convert in truncated seconds
@@ -992,6 +994,14 @@ -(void)unreadCountDone:(NSMutableURLRequest *)request response:(NSURLResponse *)
992994
}
993995
}
994996
}
997+
998+
NSArray *localFolders = [Database sharedManager].arrayOfAllFolders;
999+
for (Folder *folder in localFolders) {
1000+
// folders which are locally marked as having unread articles, while they are remotely all read
1001+
if (folder.isOpenReaderFolder && folder.unreadCount > 0 && ![remoteUnreadFeeds containsObject:folder.remoteId]) {
1002+
[folder clearNonPersistedFlag:VNAFolderFlagSyncedOK];
1003+
}
1004+
}
9951005
} // unreadCountDone
9961006

9971007
-(void)subscribeToFeed:(NSString *)feedURL withLabel:(NSString *)label

0 commit comments

Comments
 (0)