mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Background tasking unreading of stories.
This commit is contained in:
parent
83dcf5640b
commit
9b4c916883
2 changed files with 34 additions and 26 deletions
|
@ -362,17 +362,22 @@
|
||||||
NSString *storyFeedId = [request.userInfo objectForKey:@"story_feed_id"];
|
NSString *storyFeedId = [request.userInfo objectForKey:@"story_feed_id"];
|
||||||
NSString *storyHash = [request.userInfo objectForKey:@"story_hash"];
|
NSString *storyHash = [request.userInfo objectForKey:@"story_hash"];
|
||||||
|
|
||||||
BOOL dequeued = [appDelegate dequeueReadStoryHash:storyHash inFeed:storyFeedId];
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
|
||||||
if (!dequeued) {
|
(unsigned long)NULL), ^(void) {
|
||||||
// Offline means can't unread a story unless it was read while offline.
|
BOOL dequeued = [appDelegate dequeueReadStoryHash:storyHash inFeed:storyFeedId];
|
||||||
[self markStoryRead:storyHash feedId:storyFeedId];
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
// [self.storyTitlesTable reloadData];
|
if (!dequeued) {
|
||||||
[appDelegate failedMarkAsUnread:request];
|
// Offline means can't unread a story unless it was read while offline.
|
||||||
} else {
|
[self markStoryRead:storyHash feedId:storyFeedId];
|
||||||
// Offline but read story while offline, so it never touched the server.
|
// [self.storyTitlesTable reloadData];
|
||||||
[appDelegate.unreadStoryHashes setObject:[NSNumber numberWithBool:YES] forKey:storyHash];
|
[appDelegate failedMarkAsUnread:request];
|
||||||
// [self.storyTitlesTable reloadData];
|
} 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
|
#pragma mark - Story Actions
|
||||||
|
@ -551,20 +556,23 @@
|
||||||
if (!newUnreadCounts) return;
|
if (!newUnreadCounts) return;
|
||||||
[appDelegate.dictUnreadCounts setObject:newUnreadCounts forKey:feedIdStr];
|
[appDelegate.dictUnreadCounts setObject:newUnreadCounts forKey:feedIdStr];
|
||||||
|
|
||||||
[appDelegate.database inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
|
||||||
NSString *storyHash = [newStory objectForKey:@"story_hash"];
|
(unsigned long)NULL), ^(void) {
|
||||||
[db executeUpdate:@"UPDATE stories SET story_json = ? WHERE story_hash = ?",
|
[appDelegate.database inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
||||||
[newStory JSONRepresentation],
|
NSString *storyHash = [newStory objectForKey:@"story_hash"];
|
||||||
storyHash];
|
[db executeUpdate:@"UPDATE stories SET story_json = ? WHERE story_hash = ?",
|
||||||
[db executeUpdate:@"INSERT INTO unread_hashes "
|
[newStory JSONRepresentation],
|
||||||
"(story_hash, story_feed_id, story_timestamp) VALUES (?, ?, ?)",
|
storyHash];
|
||||||
storyHash, feedIdStr, [newStory objectForKey:@"story_timestamp"]];
|
[db executeUpdate:@"INSERT INTO unread_hashes "
|
||||||
[db executeUpdate:@"UPDATE unread_counts SET ps = ?, nt = ?, ng = ? WHERE feed_id = ?",
|
"(story_hash, story_feed_id, story_timestamp) VALUES (?, ?, ?)",
|
||||||
[newUnreadCounts objectForKey:@"ps"],
|
storyHash, feedIdStr, [newStory objectForKey:@"story_timestamp"]];
|
||||||
[newUnreadCounts objectForKey:@"nt"],
|
[db executeUpdate:@"UPDATE unread_counts SET ps = ?, nt = ?, ng = ? WHERE feed_id = ?",
|
||||||
[newUnreadCounts objectForKey:@"ng"],
|
[newUnreadCounts objectForKey:@"ps"],
|
||||||
feedIdStr];
|
[newUnreadCounts objectForKey:@"nt"],
|
||||||
}];
|
[newUnreadCounts objectForKey:@"ng"],
|
||||||
|
feedIdStr];
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
|
||||||
[appDelegate.recentlyReadStories removeObjectForKey:[story objectForKey:@"story_hash"]];
|
[appDelegate.recentlyReadStories removeObjectForKey:[story objectForKey:@"story_hash"]];
|
||||||
[appDelegate finishMarkAsUnread:story];
|
[appDelegate finishMarkAsUnread:story];
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#import <SystemConfiguration/SystemConfiguration.h>
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
#import <MobileCoreServices/MobileCoreServices.h>
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
|
|
||||||
#define DEBUG 1
|
//#define DEBUG 1
|
||||||
//#define PROD_DEBUG 1
|
//#define PROD_DEBUG 1
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
Loading…
Add table
Reference in a new issue