Correctly showing text or story view for stories based on story feed, not folder.

This commit is contained in:
Samuel Clay 2015-10-05 11:45:33 -07:00
parent 9806ed08f1
commit b1d9cc9e92
7 changed files with 67 additions and 34 deletions

View file

@ -369,8 +369,6 @@
[self.searchBar setShowsCancelButton:NO animated:YES]; [self.searchBar setShowsCancelButton:NO animated:YES];
} }
appDelegate.inTextView = [appDelegate.storiesCollection.activeStoryView isEqualToString:@"text"];
// [self testForTryFeed]; // [self testForTryFeed];
} }

View file

@ -96,7 +96,6 @@ SFSafariViewControllerDelegate> {
BOOL popoverHasFeedView; BOOL popoverHasFeedView;
BOOL inFeedDetail; BOOL inFeedDetail;
BOOL inStoryDetail; BOOL inStoryDetail;
BOOL inTextView;
BOOL inFindingStoryMode; BOOL inFindingStoryMode;
BOOL hasLoadedFeedDetail; BOOL hasLoadedFeedDetail;
BOOL hasQueuedReadStories; BOOL hasQueuedReadStories;
@ -131,6 +130,7 @@ SFSafariViewControllerDelegate> {
NSDictionary * dictUserProfile; NSDictionary * dictUserProfile;
NSDictionary * dictSocialServices; NSDictionary * dictSocialServices;
NSMutableDictionary * dictUnreadCounts; NSMutableDictionary * dictUnreadCounts;
NSMutableDictionary * dictTextFeeds;
NSArray * userInteractionsArray; NSArray * userInteractionsArray;
NSArray * userActivitiesArray; NSArray * userActivitiesArray;
NSMutableArray * dictFoldersArray; NSMutableArray * dictFoldersArray;
@ -200,7 +200,6 @@ SFSafariViewControllerDelegate> {
@property (nonatomic, readwrite) BOOL popoverHasFeedView; @property (nonatomic, readwrite) BOOL popoverHasFeedView;
@property (nonatomic, readwrite) BOOL inFeedDetail; @property (nonatomic, readwrite) BOOL inFeedDetail;
@property (nonatomic, readwrite) BOOL inStoryDetail; @property (nonatomic, readwrite) BOOL inStoryDetail;
@property (nonatomic, readwrite) BOOL inTextView;
@property (nonatomic, readwrite) BOOL isPresentingActivities; @property (nonatomic, readwrite) BOOL isPresentingActivities;
@property (readwrite) NSDictionary * activeStory; @property (readwrite) NSDictionary * activeStory;
@property (readwrite) NSURL * activeOriginalStoryURL; @property (readwrite) NSURL * activeOriginalStoryURL;
@ -234,6 +233,7 @@ SFSafariViewControllerDelegate> {
@property (nonatomic) NSDictionary *dictUserProfile; @property (nonatomic) NSDictionary *dictUserProfile;
@property (nonatomic) NSDictionary *dictSocialServices; @property (nonatomic) NSDictionary *dictSocialServices;
@property (nonatomic, strong) NSMutableDictionary *dictUnreadCounts; @property (nonatomic, strong) NSMutableDictionary *dictUnreadCounts;
@property (nonatomic, strong) NSMutableDictionary *dictTextFeeds;
@property (nonatomic) NSArray *userInteractionsArray; @property (nonatomic) NSArray *userInteractionsArray;
@property (nonatomic) NSArray *userActivitiesArray; @property (nonatomic) NSArray *userActivitiesArray;
@property (nonatomic) NSMutableArray *dictFoldersArray; @property (nonatomic) NSMutableArray *dictFoldersArray;
@ -307,6 +307,10 @@ SFSafariViewControllerDelegate> {
- (void)refreshUserProfile:(void(^)())callback; - (void)refreshUserProfile:(void(^)())callback;
- (void)refreshFeedCount:(id)feedId; - (void)refreshFeedCount:(id)feedId;
- (void)populateDictTextFeeds;
- (BOOL)isFeedInTextView:(id)feedId;
- (void)toggleFeedTextView:(id)feedId;
- (void)populateDictUnreadCounts; - (void)populateDictUnreadCounts;
- (NSInteger)unreadCount; - (NSInteger)unreadCount;
- (NSInteger)allUnreadCount; - (NSInteger)allUnreadCount;

View file

@ -118,7 +118,6 @@
@synthesize popoverHasFeedView; @synthesize popoverHasFeedView;
@synthesize inFeedDetail; @synthesize inFeedDetail;
@synthesize inStoryDetail; @synthesize inStoryDetail;
@synthesize inTextView;
@synthesize isPresentingActivities; @synthesize isPresentingActivities;
@synthesize activeComment; @synthesize activeComment;
@synthesize activeShareType; @synthesize activeShareType;
@ -147,6 +146,7 @@
@synthesize dictUserProfile; @synthesize dictUserProfile;
@synthesize dictSocialServices; @synthesize dictSocialServices;
@synthesize dictUnreadCounts; @synthesize dictUnreadCounts;
@synthesize dictTextFeeds;
@synthesize userInteractionsArray; @synthesize userInteractionsArray;
@synthesize userActivitiesArray; @synthesize userActivitiesArray;
@synthesize dictFoldersArray; @synthesize dictFoldersArray;
@ -640,6 +640,7 @@
self.userActivitiesArray = nil; self.userActivitiesArray = nil;
self.userInteractionsArray = nil; self.userInteractionsArray = nil;
self.dictUnreadCounts = nil; self.dictUnreadCounts = nil;
self.dictTextFeeds = nil;
[self.feedsViewController.feedTitlesTable reloadData]; [self.feedsViewController.feedTitlesTable reloadData];
[self.feedsViewController resetToolbar]; [self.feedsViewController resetToolbar];
@ -1379,6 +1380,35 @@
} }
} }
#pragma mark - Text View
- (void)populateDictTextFeeds {
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
NSDictionary *textFeeds = [preferences dictionaryForKey:@"feeds:text"];
if (!textFeeds) {
self.dictTextFeeds = [[NSMutableDictionary alloc] init];
} else {
self.dictTextFeeds = [textFeeds mutableCopy];
}
}
- (BOOL)isFeedInTextView:(id)feedId {
return [self.dictTextFeeds objectForKey:feedId];
}
- (void)toggleFeedTextView:(id)feedId {
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
if ([self.dictTextFeeds objectForKey:feedId]) {
[self.dictTextFeeds removeObjectForKey:feedId];
} else {
[self.dictTextFeeds setObject:[NSNumber numberWithBool:YES] forKey:feedId];
}
[preferences setObject:self.dictTextFeeds forKey:@"feeds:text"];
[preferences synchronize];
}
#pragma mark - Unread Counts #pragma mark - Unread Counts
- (void)populateDictUnreadCounts { - (void)populateDictUnreadCounts {

View file

@ -595,6 +595,7 @@ static UIFont *userLabelFont;
// set up dictFeeds // set up dictFeeds
appDelegate.dictFeeds = [[results objectForKey:@"feeds"] mutableCopy]; appDelegate.dictFeeds = [[results objectForKey:@"feeds"] mutableCopy];
[appDelegate populateDictUnreadCounts]; [appDelegate populateDictUnreadCounts];
[appDelegate populateDictTextFeeds];
// sort all the folders // sort all the folders
appDelegate.dictFoldersArray = [NSMutableArray array]; appDelegate.dictFoldersArray = [NSMutableArray array];

View file

@ -89,6 +89,7 @@ UIActionSheetDelegate> {
- (CGPoint)pointForGesture:(UIGestureRecognizer *)gestureRecognizer; - (CGPoint)pointForGesture:(UIGestureRecognizer *)gestureRecognizer;
- (void)showTextOrStoryView;
- (void)showStoryView; - (void)showStoryView;
- (void)fetchTextView; - (void)fetchTextView;
- (void)finishFetchTextView:(ASIHTTPRequest *)request; - (void)finishFetchTextView:(ASIHTTPRequest *)request;

View file

@ -259,10 +259,13 @@
#pragma mark Story setup #pragma mark Story setup
- (void)initStory { - (void)initStory {
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
[self.activeStory
objectForKey:@"story_feed_id"]];
appDelegate.inStoryDetail = YES; appDelegate.inStoryDetail = YES;
self.noStoryMessage.hidden = YES; self.noStoryMessage.hidden = YES;
self.webView.hidden = NO; self.webView.hidden = NO;
self.inTextView = appDelegate.inTextView; self.inTextView = NO;
[appDelegate hideShareView:NO]; [appDelegate hideShareView:NO];
} }
@ -1995,8 +1998,8 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
} }
- (void)changeWebViewWidth { - (void)changeWebViewWidth {
[webView setNeedsLayout]; // [webView setNeedsLayout];
[webView layoutIfNeeded]; // [webView layoutIfNeeded];
NSLog(@"changeWebViewWidth: %@ / %@ / %@", NSStringFromCGSize(self.view.bounds.size), NSStringFromCGSize(webView.scrollView.bounds.size), NSStringFromCGSize(webView.scrollView.contentSize)); NSLog(@"changeWebViewWidth: %@ / %@ / %@", NSStringFromCGSize(self.view.bounds.size), NSStringFromCGSize(webView.scrollView.bounds.size), NSStringFromCGSize(webView.scrollView.contentSize));
@ -2059,6 +2062,20 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
#pragma mark - #pragma mark -
#pragma mark Text view #pragma mark Text view
- (void)showTextOrStoryView {
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
[self.activeStory objectForKey:@"story_feed_id"]];
if ([appDelegate isFeedInTextView:feedIdStr]) {
if (!self.inTextView) {
[self fetchTextView];
}
} else {
if (self.inTextView) {
[self showStoryView];
}
}
}
- (void)showStoryView { - (void)showStoryView {
self.inTextView = NO; self.inTextView = NO;
[MBProgressHUD hideHUDForView:self.webView animated:YES]; [MBProgressHUD hideHUDForView:self.webView animated:YES];

View file

@ -290,7 +290,7 @@
- (void)viewDidLayoutSubviews { - (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
[self reorientPages]; // [self reorientPages];
} }
- (void)viewDidDisappear:(BOOL)animated { - (void)viewDidDisappear:(BOOL)animated {
@ -556,10 +556,7 @@
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul), ^{
[pageController initStory]; [pageController initStory];
[pageController drawStory]; [pageController drawStory];
// NSLog(@"In text view render? %d", appDelegate.inTextView); [pageController showTextOrStoryView];
if (appDelegate.inTextView) {
[pageController fetchTextView];
}
}); });
} else { } else {
// [pageController clearStory]; // [pageController clearStory];
@ -996,28 +993,13 @@
- (IBAction)toggleTextView:(id)sender { - (IBAction)toggleTextView:(id)sender {
[self endTouchDown:sender]; [self endTouchDown:sender];
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults]; NSString *feedIdStr = [NSString stringWithFormat:@"%@",
BOOL failedText = [appDelegate.storiesCollection.activeStoryView isEqualToString:@"text"] && [appDelegate.activeStory objectForKey:@"story_feed_id"]];
!currentPage.inTextView; [appDelegate toggleFeedTextView:feedIdStr];
if (!currentPage.inTextView) { [self.currentPage showTextOrStoryView];
if (!failedText) { [self.nextPage showTextOrStoryView];
// Only lock in Text view if not a failed text fetch [self.previousPage showTextOrStoryView];
[userPreferences setObject:@"text" forKey:[appDelegate.storiesCollection storyViewKey]];
}
appDelegate.inTextView = YES;
[self.currentPage fetchTextView];
[self.nextPage fetchTextView];
[self.previousPage fetchTextView];
} else {
[userPreferences setObject:@"story" forKey:[appDelegate.storiesCollection storyViewKey]];
appDelegate.inTextView = NO;
[self.currentPage showStoryView];
[self.nextPage showStoryView];
[self.previousPage showStoryView];
}
[userPreferences synchronize];
} }
#pragma mark - #pragma mark -