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];
[appDelegate.storyPageControl resizeScrollView];
[appDelegate.storyPageControl setStoryFromScroll:YES];
[appDelegate.storyPageControl advanceToNextUnread];
}
#pragma mark -

View file

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

View file

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

View file

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

View file

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