summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r--Juick/ViewControllers/FeedViewController.m23
-rw-r--r--Juick/ViewControllers/LoginViewController.h4
-rw-r--r--Juick/ViewControllers/LoginViewController.m3
3 files changed, 24 insertions, 6 deletions
diff --git a/Juick/ViewControllers/FeedViewController.m b/Juick/ViewControllers/FeedViewController.m
index f6e36f4..ce08178 100644
--- a/Juick/ViewControllers/FeedViewController.m
+++ b/Juick/ViewControllers/FeedViewController.m
@@ -12,6 +12,7 @@
#import "MessageCell.h"
#import "APIClient.h"
#import "AppDelegate.h"
+#import "LoginViewController.h"
@interface FeedViewController ()
@@ -23,14 +24,10 @@
-(void) viewDidLoad {
self.messagesDelegate = self;
self.title = @"Today";
- if ([[APIClient sharedClient] isAuthenticated]) {
- self.path = [APIClient feedUrl];
- } else {
- self.path = [APIClient messagesUrl];
- self.params = @{@"popular": @1};
- }
+ [self refreshPath];
[self setShouldScrollToBottomOnRefresh:NO];
[super viewDidLoad];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidSignedIn:) name:UserSignedInNotificationName object:nil];
}
-(void)avatarClicked:(NSString *)uname {
@@ -68,4 +65,18 @@
}
+-(void) refreshPath {
+ if ([[APIClient sharedClient] isAuthenticated]) {
+ self.path = [APIClient feedUrl];
+ } else {
+ self.path = [APIClient messagesUrl];
+ self.params = @{@"popular": @1};
+ }
+}
+
+- (void)userDidSignedIn:(User *) user {
+ [self refreshPath];
+ [self refreshData];
+}
+
@end
diff --git a/Juick/ViewControllers/LoginViewController.h b/Juick/ViewControllers/LoginViewController.h
index 12707f5..e1a4900 100644
--- a/Juick/ViewControllers/LoginViewController.h
+++ b/Juick/ViewControllers/LoginViewController.h
@@ -8,6 +8,10 @@
#import <UIKit/UIKit.h>
+#import "User.h"
+
+extern NSString * const UserSignedInNotificationName;
+
@interface LoginViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *usernameField;
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m
index 1894b1c..898e59c 100644
--- a/Juick/ViewControllers/LoginViewController.m
+++ b/Juick/ViewControllers/LoginViewController.m
@@ -11,6 +11,8 @@
#import "AppDelegate.h"
#import "APIClient.h"
+NSString * const UserSignedInNotificationName = @"UserSignedIn";
+
@interface LoginViewController()
@property (nonatomic, assign) int paddingValue;
@end
@@ -57,6 +59,7 @@
- (void) doneSignIn {
[[APIClient sharedClient] authenticate:^(User *user, NSError *error) {
if (user) {
+ [[NSNotificationCenter defaultCenter] postNotificationName:UserSignedInNotificationName object:user];
[[AppDelegate shared] registerForRemoteNotifications];
CATransition* transition = [CATransition animation];
transition.duration = 0.3;