mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Showing offline/fetching messages correctly.
This commit is contained in:
parent
eecef4bc97
commit
0c0f7cc2fb
5 changed files with 28 additions and 8 deletions
|
@ -30,7 +30,8 @@
|
|||
BOOL pageFinished;
|
||||
BOOL finishedAnimatingIn;
|
||||
BOOL isOffline;
|
||||
|
||||
BOOL isShowingOffline;
|
||||
|
||||
UITableView * storyTitlesTable;
|
||||
UIBarButtonItem * feedMarkReadButton;
|
||||
WEPopoverController *popoverController;
|
||||
|
@ -57,6 +58,7 @@
|
|||
@property (nonatomic, readwrite) BOOL pageFinished;
|
||||
@property (nonatomic, readwrite) BOOL finishedAnimatingIn;
|
||||
@property (nonatomic, readwrite) BOOL isOffline;
|
||||
@property (nonatomic, readwrite) BOOL isShowingOffline;
|
||||
|
||||
- (void)resetFeedDetail;
|
||||
- (void)reloadPage;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
@synthesize finishedAnimatingIn;
|
||||
@synthesize notifier;
|
||||
@synthesize isOffline;
|
||||
@synthesize isShowingOffline;
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
|
||||
|
@ -262,6 +263,7 @@
|
|||
self.pageFetching = NO;
|
||||
self.pageFinished = NO;
|
||||
self.isOffline = NO;
|
||||
self.isShowingOffline = NO;
|
||||
self.feedPage = 1;
|
||||
appDelegate.activeStory = nil;
|
||||
[appDelegate.storyPageControl resetPages];
|
||||
|
@ -294,6 +296,7 @@
|
|||
- (void)beginOfflineTimer {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||
if (!appDelegate.storyLocationsCount && self.feedPage == 1) {
|
||||
self.isShowingOffline = YES;
|
||||
self.isOffline = YES;
|
||||
[self showLoadingNotifier];
|
||||
[self loadOfflineStories];
|
||||
|
@ -337,7 +340,9 @@
|
|||
|
||||
if (self.isOffline) {
|
||||
[self loadOfflineStories];
|
||||
[self showOfflineNotifier];
|
||||
if (!self.isShowingOffline) {
|
||||
[self showOfflineNotifier];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -465,7 +470,9 @@
|
|||
} else {
|
||||
[self renderStories:offlineStories];
|
||||
}
|
||||
[self showOfflineNotifier];
|
||||
if (!self.isShowingOffline) {
|
||||
[self showOfflineNotifier];
|
||||
}
|
||||
});
|
||||
}];
|
||||
});
|
||||
|
@ -561,6 +568,7 @@
|
|||
return;
|
||||
} else if (self.feedPage == 1) {
|
||||
self.isOffline = YES;
|
||||
self.isShowingOffline = NO;
|
||||
[self loadOfflineStories];
|
||||
[self showOfflineNotifier];
|
||||
} else {
|
||||
|
@ -590,6 +598,7 @@
|
|||
} else if ([request responseStatusCode] >= 500) {
|
||||
if (self.feedPage == 1) {
|
||||
self.isOffline = YES;
|
||||
self.isShowingOffline = NO;
|
||||
[self loadOfflineStories];
|
||||
[self showOfflineNotifier];
|
||||
}
|
||||
|
@ -606,6 +615,7 @@
|
|||
|
||||
appDelegate.hasLoadedFeedDetail = YES;
|
||||
self.isOffline = NO;
|
||||
self.isShowingOffline = NO;
|
||||
NSString *responseString = [request responseString];
|
||||
NSData *responseData = [responseString dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSError *error;
|
||||
|
|
|
@ -425,6 +425,8 @@ static const CGFloat kFolderTitleHeight = 28;
|
|||
-(void)fetchFeedList:(BOOL)showLoader {
|
||||
NSURL *urlFeedList;
|
||||
|
||||
[appDelegate cancelOfflineQueue];
|
||||
|
||||
if (self.inPullToRefresh_) {
|
||||
urlFeedList = [NSURL URLWithString:
|
||||
[NSString stringWithFormat:@"%@/reader/feeds?flat=true&update_counts=true",
|
||||
|
@ -448,7 +450,6 @@ static const CGFloat kFolderTitleHeight = 28;
|
|||
|
||||
self.lastUpdate = [NSDate date];
|
||||
[self showRefreshNotifier];
|
||||
[appDelegate cancelOfflineQueue];
|
||||
}
|
||||
|
||||
- (void)finishedWithError:(ASIHTTPRequest *)request {
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
});
|
||||
return NO;
|
||||
}
|
||||
// NSLog(@"Fetching Stories...");
|
||||
|
||||
NSArray *hashes = [self unfetchedStoryHashes];
|
||||
NSLog(@"Fetching Stories: %@", [hashes objectAtIndex:0]);
|
||||
|
||||
if ([hashes count] == 0) {
|
||||
NSLog(@"Finished downloading unread stories. %d total", appDelegate.totalUnfetchedStoryCount);
|
||||
|
@ -83,7 +83,7 @@
|
|||
- (NSArray *)unfetchedStoryHashes {
|
||||
NSMutableArray *hashes = [NSMutableArray array];
|
||||
|
||||
[appDelegate.database inDatabase:^(FMDatabase *db) {
|
||||
[appDelegate.database inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
||||
NSString *commonQuery = @"FROM unread_hashes u "
|
||||
"LEFT OUTER JOIN stories s ON (s.story_hash = u.story_hash) "
|
||||
"WHERE s.story_hash IS NULL";
|
||||
|
@ -128,14 +128,17 @@
|
|||
(float)appDelegate.totalUnfetchedStoryCount);
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSLog(@"appDelegate.remainingUnfetchedStoryCount %d (%f)", appDelegate.remainingUnfetchedStoryCount, progress);
|
||||
[appDelegate.feedsViewController showSyncingNotifier:progress hoursBack:hours];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)storeAllUnreadStories:(NSDictionary *)results withHashes:(NSArray *)hashes {
|
||||
NSMutableArray *storyHashes = [hashes mutableCopy];
|
||||
NSLog(@"storing hashes: %@", [storyHashes objectAtIndex:0]);
|
||||
[appDelegate.database inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
||||
BOOL anyInserted = NO;
|
||||
NSLog(@"First storing: %@", [[[results objectForKey:@"stories"] objectAtIndex:0] objectForKey:@"story_hash"]);
|
||||
for (NSDictionary *story in [results objectForKey:@"stories"]) {
|
||||
NSString *storyTimestamp = [story objectForKey:@"story_timestamp"];
|
||||
BOOL inserted = [db executeUpdate:@"INSERT into stories "
|
||||
|
@ -187,7 +190,10 @@
|
|||
[db executeUpdate:[NSString stringWithFormat:@"DELETE FROM unread_hashes WHERE story_hash IN (\"%@\")",
|
||||
[storyHashes componentsJoinedByString:@"\",\" "]]];
|
||||
}
|
||||
NSLog(@"Done inserting stories (in transaction)");
|
||||
}];
|
||||
|
||||
NSLog(@"Done inserting stories");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
#import "Underscore.h"
|
||||
|
||||
//#define DEBUG 1
|
||||
#define DEBUG 1
|
||||
|
||||
#ifdef DEBUG
|
||||
#define BACKGROUND_REFRESH_SECONDS -5
|
||||
#define NEWSBLUR_URL [NSString stringWithFormat:@"http://nb.local.com"]
|
||||
#define NEWSBLUR_HOST [NSString stringWithFormat:@"nb.local.com"]
|
||||
#else
|
||||
#define BACKGROUND_REFRESH_SECONDS -10*60
|
||||
#define NEWSBLUR_URL [NSString stringWithFormat:@"https://www.newsblur.com"]
|
||||
#define NEWSBLUR_HOST [NSString stringWithFormat:@"www.newsblur.com"]
|
||||
#endif
|
||||
|
@ -20,7 +22,6 @@
|
|||
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
|
||||
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
|
||||
|
||||
#define BACKGROUND_REFRESH_SECONDS -10*60
|
||||
#define NEWSBLUR_LINK_COLOR 0x405BA8
|
||||
#define NEWSBLUR_HIGHLIGHT_COLOR 0xd2e6fd
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue