From 33539a3c9c8534776722aa1148499f984e0019e7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 2 Oct 2019 13:59:51 +0300 Subject: Move loginSegue to Tab bar controller --- Juick/ViewControllers/ThreadViewController.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Juick/ViewControllers/ThreadViewController.m') diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m index af56bc3..41e9503 100644 --- a/Juick/ViewControllers/ThreadViewController.m +++ b/Juick/ViewControllers/ThreadViewController.m @@ -10,6 +10,7 @@ #import "NewPostViewController.h" #import "MessageCell.h" #import "APIClient.h" +#import "AppDelegate.h" @implementation ThreadViewController @@ -24,7 +25,9 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:messageCellIdentifier forIndexPath:indexPath]; - [self performSegueWithIdentifier:@"replySegue" sender:cell]; + if ([self shouldPerformSegueWithIdentifier:@"replySegue" sender:self]){ + [self performSegueWithIdentifier:@"replySegue" sender:cell]; + } } -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { @@ -36,6 +39,18 @@ } } +- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { + if ([identifier isEqualToString:@"replySegue"]) { + if ([[APIClient sharedClient] isAuthenticated]) { + return YES; + } else { + [[AppDelegate shared] presentLoginView:self]; + return NO; + } + } + return YES; +} + -(void) loadMore { Message *lastMsg = [self.messages lastObject]; [self setShouldScrollToUnreadOnRefresh:lastMsg.rid > 0]; -- cgit v1.2.3