summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-10-02 13:59:51 +0300
committerGravatar Vitaly Takmazov2019-10-02 13:59:51 +0300
commit33539a3c9c8534776722aa1148499f984e0019e7 (patch)
tree6f47880a9efd4e6e240ff55c043422f68dba6936 /Juick/ViewControllers
parentd9a6f5e85d9cffed7e8bf84b6e69b27d7db67582 (diff)
Move loginSegue to Tab bar controller
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r--Juick/ViewControllers/FeedViewController.m4
-rw-r--r--Juick/ViewControllers/LoginViewController.m1
-rw-r--r--Juick/ViewControllers/ThreadViewController.m17
3 files changed, 20 insertions, 2 deletions
diff --git a/Juick/ViewControllers/FeedViewController.m b/Juick/ViewControllers/FeedViewController.m
index 31bf0ca..a5f7a43 100644
--- a/Juick/ViewControllers/FeedViewController.m
+++ b/Juick/ViewControllers/FeedViewController.m
@@ -14,6 +14,8 @@
#import "AppDelegate.h"
#import "LoginViewController.h"
+NSString * const UserNotAuthenticatedNotificationName = @"UserNotAuthenticated";
+
@interface FeedViewController ()
@property NSString *selectedUser;
@@ -50,7 +52,7 @@
if ([[APIClient sharedClient] isAuthenticated]) {
return YES;
} else {
- [self.navigationController performSegueWithIdentifier:@"loginSegue" sender:self];
+ [[AppDelegate shared] presentLoginView:self];
return NO;
}
}
diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m
index f9b17a3..55099eb 100644
--- a/Juick/ViewControllers/LoginViewController.m
+++ b/Juick/ViewControllers/LoginViewController.m
@@ -71,6 +71,7 @@ NSString * const UserSignedInNotificationName = @"UserSignedIn";
[self.navigationController dismissViewControllerAnimated:NO completion:nil];
} else {
[User throwUnableToLogin:self error:error];
+ [[APIClient sharedClient] setCredential:nil];
}
}];
}
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];