diff --git a/clients/ios/Classes/StoriesCollection.m b/clients/ios/Classes/StoriesCollection.m index c83024348..3db662d01 100644 --- a/clients/ios/Classes/StoriesCollection.m +++ b/clients/ios/Classes/StoriesCollection.m @@ -362,17 +362,22 @@ NSString *storyFeedId = [request.userInfo objectForKey:@"story_feed_id"]; NSString *storyHash = [request.userInfo objectForKey:@"story_hash"]; - BOOL dequeued = [appDelegate dequeueReadStoryHash:storyHash inFeed:storyFeedId]; - if (!dequeued) { - // Offline means can't unread a story unless it was read while offline. - [self markStoryRead:storyHash feedId:storyFeedId]; -// [self.storyTitlesTable reloadData]; - [appDelegate failedMarkAsUnread:request]; - } else { - // Offline but read story while offline, so it never touched the server. - [appDelegate.unreadStoryHashes setObject:[NSNumber numberWithBool:YES] forKey:storyHash]; -// [self.storyTitlesTable reloadData]; - } + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, + (unsigned long)NULL), ^(void) { + BOOL dequeued = [appDelegate dequeueReadStoryHash:storyHash inFeed:storyFeedId]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (!dequeued) { + // Offline means can't unread a story unless it was read while offline. + [self markStoryRead:storyHash feedId:storyFeedId]; + // [self.storyTitlesTable reloadData]; + [appDelegate failedMarkAsUnread:request]; + } else { + // Offline but read story while offline, so it never touched the server. + [appDelegate.unreadStoryHashes setObject:[NSNumber numberWithBool:YES] forKey:storyHash]; + // [self.storyTitlesTable reloadData]; + } + }); + }); } #pragma mark - Story Actions @@ -551,20 +556,23 @@ if (!newUnreadCounts) return; [appDelegate.dictUnreadCounts setObject:newUnreadCounts forKey:feedIdStr]; - [appDelegate.database inTransaction:^(FMDatabase *db, BOOL *rollback) { - NSString *storyHash = [newStory objectForKey:@"story_hash"]; - [db executeUpdate:@"UPDATE stories SET story_json = ? WHERE story_hash = ?", - [newStory JSONRepresentation], - storyHash]; - [db executeUpdate:@"INSERT INTO unread_hashes " - "(story_hash, story_feed_id, story_timestamp) VALUES (?, ?, ?)", - storyHash, feedIdStr, [newStory objectForKey:@"story_timestamp"]]; - [db executeUpdate:@"UPDATE unread_counts SET ps = ?, nt = ?, ng = ? WHERE feed_id = ?", - [newUnreadCounts objectForKey:@"ps"], - [newUnreadCounts objectForKey:@"nt"], - [newUnreadCounts objectForKey:@"ng"], - feedIdStr]; - }]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, + (unsigned long)NULL), ^(void) { + [appDelegate.database inTransaction:^(FMDatabase *db, BOOL *rollback) { + NSString *storyHash = [newStory objectForKey:@"story_hash"]; + [db executeUpdate:@"UPDATE stories SET story_json = ? WHERE story_hash = ?", + [newStory JSONRepresentation], + storyHash]; + [db executeUpdate:@"INSERT INTO unread_hashes " + "(story_hash, story_feed_id, story_timestamp) VALUES (?, ?, ?)", + storyHash, feedIdStr, [newStory objectForKey:@"story_timestamp"]]; + [db executeUpdate:@"UPDATE unread_counts SET ps = ?, nt = ?, ng = ? WHERE feed_id = ?", + [newUnreadCounts objectForKey:@"ps"], + [newUnreadCounts objectForKey:@"nt"], + [newUnreadCounts objectForKey:@"ng"], + feedIdStr]; + }]; + }); [appDelegate.recentlyReadStories removeObjectForKey:[story objectForKey:@"story_hash"]]; [appDelegate finishMarkAsUnread:story]; diff --git a/clients/ios/NewsBlur_Prefix.pch b/clients/ios/NewsBlur_Prefix.pch index 84c4b27cc..61a690f4d 100644 --- a/clients/ios/NewsBlur_Prefix.pch +++ b/clients/ios/NewsBlur_Prefix.pch @@ -5,7 +5,7 @@ #import #import -#define DEBUG 1 +//#define DEBUG 1 //#define PROD_DEBUG 1 #ifdef DEBUG