From a8c7c8cfaaed64856908d9edc03cbc90f8472a02 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Wed, 17 Jul 2013 19:00:00 -0700 Subject: [PATCH] Handling canceled feed detail loads. --- clients/ios/Classes/FeedDetailViewController.m | 8 ++++++-- clients/ios/Classes/NewsBlurAppDelegate.h | 4 +++- clients/ios/Classes/NewsBlurAppDelegate.m | 1 + clients/ios/NewsBlur_Prefix.pch | 8 ++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/clients/ios/Classes/FeedDetailViewController.m b/clients/ios/Classes/FeedDetailViewController.m index b6e4cd21b..04dad29f7 100644 --- a/clients/ios/Classes/FeedDetailViewController.m +++ b/clients/ios/Classes/FeedDetailViewController.m @@ -121,7 +121,7 @@ - (void)viewWillAppear:(BOOL)animated { UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; [self setUserAvatarLayout:orientation]; - + [self cancelRequests]; self.finishedAnimatingIn = NO; self.pageFinished = NO; [MBProgressHUD hideHUDForView:self.view animated:YES]; @@ -354,7 +354,10 @@ [request setDefaultResponseEncoding:NSUTF8StringEncoding]; [request setFailedBlock:^(void) { NSLog(@"in failed block %@", request); - if (self.feedPage == 1) { + if (request.isCancelled) { + NSLog(@"Cancelled"); + return; + } else if (self.feedPage == 1) { self.isOffline = YES; [self loadOfflineStories]; [self showOfflineNotifier]; @@ -373,6 +376,7 @@ [request setTimeOutSeconds:30]; [request setTag:[[[appDelegate activeFeed] objectForKey:@"id"] intValue]]; [request startAsynchronous]; + [requests addObject:request]; } } diff --git a/clients/ios/Classes/NewsBlurAppDelegate.h b/clients/ios/Classes/NewsBlurAppDelegate.h index 04a423a62..03cb3b66a 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.h +++ b/clients/ios/Classes/NewsBlurAppDelegate.h @@ -90,7 +90,8 @@ BOOL inFeedDetail; BOOL inStoryDetail; BOOL inFindingStoryMode; - BOOL hashQueuedReadStories; + BOOL feedDetailLoaded; + BOOL hasQueuedReadStories; NSString *tryFeedStoryId; NSDictionary * activeFeed; NSMutableDictionary * activeClassifiers; @@ -185,6 +186,7 @@ @property (nonatomic, readwrite) BOOL isSocialRiverView; @property (nonatomic, readwrite) BOOL isTryFeedView; @property (nonatomic, readwrite) BOOL inFindingStoryMode; +@property (nonatomic, readwrite) BOOL feedDetailLoaded; @property (nonatomic) NSString *tryFeedStoryId; @property (nonatomic) NSString *tryFeedCategory; @property (nonatomic, readwrite) BOOL popoverHasFeedView; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index d28fe709d..9f7963cb9 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -97,6 +97,7 @@ @synthesize isTryFeedView; @synthesize inFindingStoryMode; +@synthesize feedDetailLoaded; @synthesize tryFeedStoryId; @synthesize tryFeedCategory; @synthesize popoverHasFeedView; diff --git a/clients/ios/NewsBlur_Prefix.pch b/clients/ios/NewsBlur_Prefix.pch index 7fb4d3eb7..7353fe895 100644 --- a/clients/ios/NewsBlur_Prefix.pch +++ b/clients/ios/NewsBlur_Prefix.pch @@ -13,10 +13,10 @@ // #define BACKGROUND_REFRESH_SECONDS -5 #define BACKGROUND_REFRESH_SECONDS -10*60 -// #define NEWSBLUR_URL [NSString stringWithFormat:@"http://nb.local.com"] -// #define NEWSBLUR_HOST [NSString stringWithFormat:@"nb.local.com"] - #define NEWSBLUR_URL [NSString stringWithFormat:@"https://www.newsblur.com"] - #define NEWSBLUR_HOST [NSString stringWithFormat:@"www.newsblur.com"] + #define NEWSBLUR_URL [NSString stringWithFormat:@"http://nb.local.com"] + #define NEWSBLUR_HOST [NSString stringWithFormat:@"nb.local.com"] +// #define NEWSBLUR_URL [NSString stringWithFormat:@"https://www.newsblur.com"] +// #define NEWSBLUR_HOST [NSString stringWithFormat:@"www.newsblur.com"] #define NEWSBLUR_LINK_COLOR 0x405BA8 #define NEWSBLUR_HIGHLIGHT_COLOR 0xd2e6fd