summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/DiscoverViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers/DiscoverViewController.m')
-rw-r--r--Juick/ViewControllers/DiscoverViewController.m23
1 files changed, 23 insertions, 0 deletions
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