summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/FeedViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers/FeedViewController.m')
-rw-r--r--Juick/ViewControllers/FeedViewController.m64
1 files changed, 22 insertions, 42 deletions
diff --git a/Juick/ViewControllers/FeedViewController.m b/Juick/ViewControllers/FeedViewController.m
index b6b578f..f6e36f4 100644
--- a/Juick/ViewControllers/FeedViewController.m
+++ b/Juick/ViewControllers/FeedViewController.m
@@ -23,7 +23,12 @@
-(void) viewDidLoad {
self.messagesDelegate = self;
self.title = @"Today";
- self.path = [APIClient feedUrl];
+ if ([[APIClient sharedClient] isAuthenticated]) {
+ self.path = [APIClient feedUrl];
+ } else {
+ self.path = [APIClient messagesUrl];
+ self.params = @{@"popular": @1};
+ }
[self setShouldScrollToBottomOnRefresh:NO];
[super viewDidLoad];
}
@@ -32,47 +37,6 @@
self.selectedUser = uname;
[self performSegueWithIdentifier:@"profileSegue" sender:self];
}
-/*
-- (IBAction)filterAction:(id)sender {
- if (![[APIClient sharedClient] isAuthenticated]) {
- [self.navigationController performSegueWithIdentifier:@"loginSegue" sender:self.navigationController];
- return;
- }
- UIAlertController *filterAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"My feed" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- self.path = [APIClient feedUrl];
- self.navigationController.visibleViewController.navigationItem.title = @"My feed";
- self.params = nil;
- [self.messages removeAllObjects];
- [self.tableView reloadData];
- [self setShouldScrollToBottomOnRefresh:NO];
- }]];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discover" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- self.path = [APIClient messagesUrl];
- self.navigationController.visibleViewController.navigationItem.title = @"Discover";
- self.params = nil;
- [self.messages removeAllObjects];
- [self.tableView reloadData];
- [self setShouldScrollToBottomOnRefresh:NO];
- }]];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discussions" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- self.path = [APIClient discussionsUrl];
- self.navigationController.visibleViewController.navigationItem.title = @"Discussions";
- self.params = nil;
- [self.messages removeAllObjects];
- [self.tableView reloadData];
- [self setShouldScrollToBottomOnRefresh:NO];
- }]];
- [filterAlert.view setTintColor:[ColorScheme linkColor]];
- UIPopoverPresentationController *popover = [filterAlert popoverPresentationController];
- if (popover) {
- popover.sourceView = self.view;
- popover.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 0, 0);
- popover.permittedArrowDirections = UIPopoverArrowDirectionUp;
- }
- [self presentViewController:filterAlert animated:YES completion:nil];
-}*/
-(void) loadMore {
Message *lastMsg = [self.messages lastObject];
@@ -88,4 +52,20 @@
}
}
+- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
+ if ([identifier isEqualToString:@"newPostSegue"]) {
+ if ([[APIClient sharedClient] isAuthenticated]) {
+ return YES;
+ } else {
+ [self.navigationController performSegueWithIdentifier:@"loginSegue" sender:self];
+ return NO;
+ }
+ }
+ return YES;
+}
+
+- (void)didReceiveChallenge {
+
+}
+
@end