From 5d0e97b3c1a1910a036f455b67205bc5eece1c29 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 3 Mar 2018 21:33:11 +0300 Subject: discussions --- Juick/ViewControllers/DiscoverViewController.m | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Juick/ViewControllers/DiscoverViewController.m') diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index c027ea7..1b1a0a1 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -22,6 +22,7 @@ AppDelegate *appDelegate; -(void) viewDidLoad { [super viewDidLoad]; + self.messagesDelegate = self; if ([User isAuthenticated]) { [User checkIsValid:^(BOOL success) { if (success) { @@ -91,7 +92,29 @@ AppDelegate *appDelegate; [self.tableView reloadData]; [self refreshData:NO]; }]]; + [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discussions" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self setTitle:@"Discussions"]; + self.path = [APIClient discussionsUrl]; + self.params = nil; + [self.messages removeAllObjects]; + [self.tableView reloadData]; + [self refreshData:NO]; + }]]; [self presentViewController:filterAlert animated:YES completion:nil]; } +-(void) loadMore { + Message *lastMsg = [self.messages lastObject]; + if (lastMsg != nil) { + if ([self.path isEqualToString:[APIClient discussionsUrl]]) { + NSDate *msgDate = [[APIClient sharedClient].dateFormatter dateFromString:lastMsg.timestamp]; + self.params = [@{@"to" : [NSString stringWithFormat:@"%.0f", [msgDate timeIntervalSince1970] * 1000]} mutableCopy]; + } else if (![self.path isEqualToString:[APIClient threadUrl]]) { + NSNumber *lastMid = lastMsg.mid; + self.params = [@{@"before_mid":lastMid} mutableCopy]; + } + [self refreshData:NO]; + } +} + @end -- cgit v1.2.3