Fixing bug in ios where hitting next unread while story page controls was already waiting on a page fetch would not automatically advance to the next unread story.

This commit is contained in:
Samuel Clay 2012-12-13 16:41:52 -08:00
parent cc1eb7e230
commit 9a3b76c808
5 changed files with 27 additions and 6 deletions

View file

@ -481,6 +481,7 @@
[self renderStories:confirmedNewStories]; [self renderStories:confirmedNewStories];
[appDelegate.storyPageControl resizeScrollView]; [appDelegate.storyPageControl resizeScrollView];
[appDelegate.storyPageControl setStoryFromScroll:YES]; [appDelegate.storyPageControl setStoryFromScroll:YES];
[appDelegate.storyPageControl advanceToNextUnread];
} }
#pragma mark - #pragma mark -

View file

@ -631,6 +631,7 @@
" %@" " %@"
" <div class=\"NB-story-comment-username\">%@</div>" " <div class=\"NB-story-comment-username\">%@</div>"
" <div class=\"NB-story-comment-date\">%@ ago</div>" " <div class=\"NB-story-comment-date\">%@ ago</div>"
" <div class=\"NB-story-comment-likes\">%@</div>"
"</div>" "</div>"
"<div class=\"NB-story-comment-content\">%@</div>" "<div class=\"NB-story-comment-content\">%@</div>"
"%@" // location "%@" // location
@ -652,6 +653,7 @@
userReshareString, userReshareString,
[user objectForKey:@"username"], [user objectForKey:@"username"],
[commentDict objectForKey:@"shared_date"], [commentDict objectForKey:@"shared_date"],
likingUsers,
commentContent, commentContent,
locationHtml, locationHtml,
[commentDict objectForKey:@"user_id"], [commentDict objectForKey:@"user_id"],
@ -926,7 +928,11 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
height:[[urlComponents objectAtIndex:6] intValue]]; height:[[urlComponents objectAtIndex:6] intValue]];
return NO; return NO;
} }
} else if ([url.host hasSuffix:@"itunes.apple.com"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
} }
if (navigationType == UIWebViewNavigationTypeLinkClicked) { if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[appDelegate showOriginalStory:url]; [appDelegate showOriginalStory:url];
return NO; return NO;

View file

@ -32,6 +32,7 @@
Class popoverClass; Class popoverClass;
BOOL isDraggingScrollview; BOOL isDraggingScrollview;
BOOL waitingForNextUnreadFromServer;
} }
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate; @property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@ -56,6 +57,7 @@
@property (nonatomic, strong) IBOutlet UIBarButtonItem *subscribeButton; @property (nonatomic, strong) IBOutlet UIBarButtonItem *subscribeButton;
@property (readwrite) CGFloat inTouchMove; @property (readwrite) CGFloat inTouchMove;
@property (assign) BOOL isDraggingScrollview; @property (assign) BOOL isDraggingScrollview;
@property (assign) BOOL waitingForNextUnreadFromServer;
@property (nonatomic) MBProgressHUD *storyHUD; @property (nonatomic) MBProgressHUD *storyHUD;
@property (nonatomic) int scrollingToPage; @property (nonatomic) int scrollingToPage;
@ -70,6 +72,7 @@
- (void)refreshHeaders; - (void)refreshHeaders;
- (void)setStoryFromScroll; - (void)setStoryFromScroll;
- (void)setStoryFromScroll:(BOOL)force; - (void)setStoryFromScroll:(BOOL)force;
- (void)advanceToNextUnread;
- (void)updatePageWithActiveStory:(int)location; - (void)updatePageWithActiveStory:(int)location;
- (void)changePage:(NSInteger)pageIndex; - (void)changePage:(NSInteger)pageIndex;
- (void)changePage:(NSInteger)pageIndex animated:(BOOL)animated; - (void)changePage:(NSInteger)pageIndex animated:(BOOL)animated;

View file

@ -44,6 +44,7 @@
@synthesize loadingIndicator; @synthesize loadingIndicator;
@synthesize inTouchMove; @synthesize inTouchMove;
@synthesize isDraggingScrollview; @synthesize isDraggingScrollview;
@synthesize waitingForNextUnreadFromServer;
@synthesize storyHUD; @synthesize storyHUD;
@synthesize scrollingToPage; @synthesize scrollingToPage;
@ -314,7 +315,7 @@
if (newIndex > 0 && newIndex >= [appDelegate.activeFeedStoryLocations count]) { if (newIndex > 0 && newIndex >= [appDelegate.activeFeedStoryLocations count]) {
pageController.pageIndex = -2; pageController.pageIndex = -2;
if (self.appDelegate.feedDetailViewController.feedPage < 50 && if (self.appDelegate.feedDetailViewController.feedPage < 100 &&
!self.appDelegate.feedDetailViewController.pageFinished && !self.appDelegate.feedDetailViewController.pageFinished &&
!self.appDelegate.feedDetailViewController.pageFetching) { !self.appDelegate.feedDetailViewController.pageFetching) {
[self.appDelegate.feedDetailViewController fetchNextPage:^() { [self.appDelegate.feedDetailViewController fetchNextPage:^() {
@ -518,6 +519,15 @@
} }
} }
- (void)advanceToNextUnread {
if (!self.waitingForNextUnreadFromServer) {
return;
}
self.waitingForNextUnreadFromServer = NO;
[self doNextUnreadStory];
}
- (void)updatePageWithActiveStory:(int)location { - (void)updatePageWithActiveStory:(int)location {
[self markStoryAsRead]; [self markStoryAsRead];
[appDelegate pushReadStory:[appDelegate.activeStory objectForKey:@"id"]]; [appDelegate pushReadStory:[appDelegate.activeStory objectForKey:@"id"]];
@ -909,15 +919,16 @@
int unreadCount = [appDelegate unreadCount]; int unreadCount = [appDelegate unreadCount];
[self.loadingIndicator stopAnimating]; [self.loadingIndicator stopAnimating];
NSLog(@"doNextUnreadStory: %d (out of %d)", nextLocation, unreadCount);
if (nextLocation == -1 && unreadCount > 0 && if (nextLocation == -1 && unreadCount > 0 &&
fdvc.feedPage < 50) { fdvc.feedPage < 100) {
[self.loadingIndicator startAnimating]; [self.loadingIndicator startAnimating];
self.activity.customView = self.loadingIndicator; self.activity.customView = self.loadingIndicator;
self.buttonNext.enabled = NO; self.buttonNext.enabled = NO;
// Fetch next page and see if it has the unreads. // Fetch next page and see if it has the unreads.
[fdvc fetchNextPage:^() { self.waitingForNextUnreadFromServer = YES;
[self doNextUnreadStory]; [fdvc fetchNextPage:nil];
}];
} else if (nextLocation == -1) { } else if (nextLocation == -1) {
[appDelegate.navigationController [appDelegate.navigationController
popToViewController:[appDelegate.navigationController.viewControllers popToViewController:[appDelegate.navigationController.viewControllers

View file

@ -5,7 +5,7 @@
<key>application-identifier</key> <key>application-identifier</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string> <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>get-task-allow</key> <key>get-task-allow</key>
<false/> <true/>
<key>keychain-access-groups</key> <key>keychain-access-groups</key>
<array> <array>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string> <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>