summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/DiscoverViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-03 21:33:11 +0300
committerGravatar Vitaly Takmazov2018-03-03 21:33:11 +0300
commit5d0e97b3c1a1910a036f455b67205bc5eece1c29 (patch)
tree5878f990e43ac5b2f163764bfa7f9226a962b8f3 /Juick/ViewControllers/DiscoverViewController.m
parent3e0b7455926477ee5cce1233bf1bf1d6f2bd63f8 (diff)
discussions
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