Fix: keep unread state if open unread articles failed

This commit is contained in:
relikd
2019-07-23 15:49:45 +02:00
parent 666ecd154f
commit 85cc12f34a
6 changed files with 30 additions and 22 deletions

View File

@@ -80,15 +80,16 @@
NSManagedObjectContext *moc = [StoreCoordinator createChildContext];
FeedArticle *fa = [moc objectWithID:sender.representedObject];
NSString *url = fa.link;
if (flipUnread || fa.unread) {
BOOL success = NO;
if (url && url.length > 0 && !flipUnread) // flipUnread == change unread state
success = [UserPrefs openURLsWithPreferredBrowser:@[[NSURL URLWithString:url]]];
if (flipUnread || (success && fa.unread)) {
fa.unread = !fa.unread;
NSNumber *num = (fa.unread ? @+1 : @-1);
[StoreCoordinator saveContext:moc andParent:YES];
NSNumber *num = (fa.unread ? @+1 : @-1);
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountChanged object:num];
}
[moc reset];
if (url && url.length > 0 && !flipUnread) // flipUnread == change unread state
[UserPrefs openURLsWithPreferredBrowser:@[[NSURL URLWithString:url]]];
}
@end