summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/DiscoverViewController.m
blob: 4b229792816789f3e59d721382ce4615cff2c054 (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
//
//  DiscoverViewController.m
//  Juick
//
//  Created by Vitaly Takmazov on 03/12/2017.
//  Copyright © 2017 com.juick. All rights reserved.
//

#import "DiscoverViewController.h"
#import "ThreadViewController.h"
#import "MessageCell.h"
#import "APIClient.h"

@interface DiscoverViewController ()

@end

@implementation DiscoverViewController



-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString * cellIdentifier = @"messageCell";
    MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    [self performSegueWithIdentifier:@"threadViewSegue" sender:cell];
}

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqual: @"threadViewSegue"]) {
        Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row];
        ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController;
        [threadVC setPath:[APIClient threadUrl]];
        [threadVC setParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:msg.mid, @"mid", nil]];
    }
}

@end