blob: 60a115f6704f2bd76bd2f098f3336aac32f7cb9f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
//
// 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"
#import "APIClient.h"
#import "AppDelegate.h"
@implementation ThreadViewController
-(void) viewDidLoad {
[self setTitle:@"Thread"];
[self setPath:[APIClient 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];
}
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqual: @"editorSegue"]) {
Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row];
NewPostViewController *postVC = (NewPostViewController *)segue.destinationViewController;
[postVC setReplyTo:msg];
}
}
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
if ([identifier isEqualToString:@"editorSegue"]) {
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];
[self refreshData];
}
- (void)replyPosted:(NSNotification *) notification {
[self setShouldScrollToUnreadOnRefresh:YES];
[self refreshData];
}
@end
|