summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/JuickNavigationController.m
blob: a066dbd4b4174e955b6e51a89a0770cf4941ff66 (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
64
65
//
//  JuickNavigationController.m
//  Juick
//
//  Created by Vitaly Takmazov on 02/10/2019.
//  Copyright © 2019 com.juick. All rights reserved.
//

#import "JuickNavigationController.h"

#import "AppDelegate.h"
#import "APIClient.h"
#import "MessagesViewController.h"
#import "ThreadViewController.h"

#import "Message.h"

@interface JuickNavigationController ()


@end

@implementation JuickNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

#pragma mark - Navigation

- (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)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"threadSegue"]) {
        if ([sender isKindOfClass:[MessagesViewController class]]) {
            MessagesViewController *vc = (MessagesViewController *) sender;
            Message *msg = vc.messages[vc.tableView.indexPathForSelectedRow.row];
            ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController;
            [threadVC setMessages:[@[msg] mutableCopy]];
            [threadVC setParams:@{@"mid": msg.mid }];
            [threadVC setShouldScrollToUnreadOnRefresh:NO];
        }
        /*
        if (rid) {
            [threadVC setFirstUnread:rid];
            [threadVC setShouldScrollToUnreadOnRefresh:YES];
        }*/
    }
}

- (IBAction)newMessage:(id)sender {
    [[AppDelegate shared] presentLoginView:self];
}
@end