diff options
author | Vitaly Takmazov | 2019-03-22 00:56:41 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-22 00:56:41 +0300 |
commit | 78412d188e8cf119046ee8b2344a07674ccf7f43 (patch) | |
tree | b97287947b07bc63a05fb4a8607ccc4bf19aa747 /Juick | |
parent | 5f4a09ec689cb04ce71b4eb7425936f04a70f6f4 (diff) |
Fix today feed
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/AppDelegate.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/FeedViewController.m | 23 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.h | 4 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.m | 3 |
4 files changed, 25 insertions, 6 deletions
diff --git a/Juick/AppDelegate.h b/Juick/AppDelegate.h index 59dd7f5..3316d3f 100644 --- a/Juick/AppDelegate.h +++ b/Juick/AppDelegate.h @@ -8,6 +8,7 @@ @import UIKit; #import "ThreadViewController.h" +#import "User.h" @interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate> 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; |