// // DiscoverViewController.m // Juick // // Created by Vitaly Takmazov on 03/12/2017. // Copyright © 2017 com.juick. All rights reserved. // #import "FeedViewController.h" #import "ThreadViewController.h" #import "BlogViewController.h" #import "MessageCell.h" #import "LoginViewController.h" NSString * const UserNotAuthenticatedNotificationName = @"UserNotAuthenticated"; @interface FeedViewController () @property NSString *selectedUser; @end @implementation FeedViewController -(void) viewDidLoad { self.messagesDelegate = self; [self refreshPath]; [self setShouldScrollToUnreadOnRefresh:NO]; [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidSignedIn:) name:UserChangedNotificationName object:nil]; } -(void)avatarClicked:(NSString *)uname { self.selectedUser = uname; [self performSegueWithIdentifier:@"profileSegue" sender:self]; } -(void) loadMore { Message *lastMsg = [self.messages lastObject]; if (lastMsg != nil) { NSNumber *lastMid = lastMsg.mid; self.params = [@{@"before_mid":lastMid} mutableCopy]; [self setShouldScrollToUnreadOnRefresh:NO]; [self refreshData]; } } -(void) refreshPath { if ([[AppDelegate shared].api currentUser]) { self.path = [API feedUrl]; } else { self.path = [API messagesUrl]; self.params = @{@"popular": @1}; } } - (void)userDidSignedIn:(NSNotification *) notification { [self refreshPath]; [self refreshData]; } @end