diff options
author | Vitaly Takmazov | 2018-10-31 00:13:21 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-31 00:13:21 +0300 |
commit | 2d6630dda9f7c3df0da956c4644f94342d2bb747 (patch) | |
tree | cc312797eb058112dab712ed66adb26ab53d1431 /Juick/ViewControllers/DiscoverViewController.m | |
parent | f7f877b0c5a928530d2422937402a983c402743f (diff) |
Refresh data on path changes
Diffstat (limited to 'Juick/ViewControllers/DiscoverViewController.m')
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index b09e1df..092c19c 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -23,7 +23,6 @@ @implementation DiscoverViewController -(void) viewDidLoad { - [super viewDidLoad]; self.messagesDelegate = self; if ([User isAuthenticated]) { [User checkIsValid:^(BOOL success) { @@ -33,7 +32,8 @@ [self.tabBarItem setTitle:@"My feed"]; self.navigationController.visibleViewController.navigationItem.title = @"My feed"; } - [self refreshData:NO]; + [self setShouldScrollToBottomOnRefresh:NO]; + [self refreshData]; } else { [User throwUnableToLogin:self]; } @@ -45,8 +45,10 @@ [self.tabBarItem setTitle:@"Discover"]; self.navigationController.visibleViewController.navigationItem.title = @"Discover"; } - [self refreshData:NO]; + [self setShouldScrollToBottomOnRefresh:NO]; + [self refreshData]; } + [super viewDidLoad]; self.appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate; } @@ -83,17 +85,19 @@ Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; mid = msg.mid; } - ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController; - [threadVC setPath:[APIClient threadUrl]]; - [threadVC setParams:@{@"mid": mid }]; - [threadVC refreshData:scrollToEnd]; + if ([mid integerValue] > 0) { + ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController; + [threadVC setPath:[APIClient threadUrl]]; + [threadVC setParams:@{@"mid": mid }]; + [threadVC setShouldScrollToBottomOnRefresh:scrollToEnd]; + } } if ([segue.identifier isEqual: @"profileSegue"]) { BlogViewController *blogVC = (BlogViewController *)segue.destinationViewController; [blogVC setUname:self.selectedUser]; [blogVC setTitle:self.selectedUser]; blogVC.path = [NSString stringWithFormat:@"/messages?uname=%@", self.selectedUser]; - [blogVC refreshData:NO]; + [blogVC setShouldScrollToBottomOnRefresh:NO]; } } - (IBAction)filterAction:(id)sender { @@ -110,7 +114,7 @@ self.params = nil; [self.messages removeAllObjects]; [self.tableView reloadData]; - [self refreshData:NO]; + [self setShouldScrollToBottomOnRefresh:NO]; }]]; [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discover" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { self.path = [APIClient messagesUrl]; @@ -119,7 +123,7 @@ self.params = nil; [self.messages removeAllObjects]; [self.tableView reloadData]; - [self refreshData:NO]; + [self setShouldScrollToBottomOnRefresh:NO]; }]]; [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discussions" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { self.path = [APIClient discussionsUrl]; @@ -128,7 +132,7 @@ self.params = nil; [self.messages removeAllObjects]; [self.tableView reloadData]; - [self refreshData:NO]; + [self setShouldScrollToBottomOnRefresh:NO]; }]]; [filterAlert.view setTintColor:[ColorScheme linkColor]]; UIPopoverPresentationController *popover = [filterAlert popoverPresentationController]; @@ -150,7 +154,7 @@ NSNumber *lastMid = lastMsg.mid; self.params = [@{@"before_mid":lastMid} mutableCopy]; } - [self refreshData:NO]; + [self setShouldScrollToBottomOnRefresh:NO]; } } |