// // ThreadViewController.m // Juick // // Created by Vitaly Takmazov on 24/09/2017. // Copyright © 2017 com.juick. All rights reserved. // #import "ThreadViewController.h" #import "NewPostViewController.h" #import "MessageCell.h" @implementation ThreadViewController -(void) viewDidLoad { [self setPath:[API threadUrl]]; [super viewDidLoad]; self.messagesDelegate = self; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(replyPosted:) name:ReplyPostedNotificationName object:nil]; } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([self shouldPerformSegueWithIdentifier:@"editorSegue" sender:self]){ [[AppDelegate shared] presentEditor:self]; } } - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { if ([identifier isEqualToString:@"editorSegue"]) { if ([[NSUserDefaults standardUserDefaults] stringForKey:@"token"]) { return YES; } else { [[AppDelegate shared] unauthorized]; return NO; } } return YES; } -(void) loadMore { Message *lastMsg = [self.messages lastObject]; [self setShouldScrollToUnreadOnRefresh:lastMsg.rid > 0]; [self refreshData]; } - (void)replyPosted:(NSNotification *) notification { [self setShouldScrollToUnreadOnRefresh:YES]; [self refreshData]; } - (BOOL)shouldAllowToSelectText { return YES; } @end