diff options
author | Vitaly Takmazov | 2019-03-22 00:33:30 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-22 00:33:30 +0300 |
commit | 5f4a09ec689cb04ce71b4eb7425936f04a70f6f4 (patch) | |
tree | 9653dc543bd8f47dbfa853cd36ace63206efc983 /Juick/ViewControllers/FeedViewController.m | |
parent | 6e49fc5c4273e7597925c133c3a6985b6ad85ecc (diff) |
Fix sign in
Diffstat (limited to 'Juick/ViewControllers/FeedViewController.m')
-rw-r--r-- | Juick/ViewControllers/FeedViewController.m | 64 |
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 |