summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/MessagesViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers/MessagesViewController.m')
-rw-r--r--Juick/ViewControllers/MessagesViewController.m31
1 files changed, 20 insertions, 11 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m
index b91f056..5a1521d 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -69,16 +69,18 @@
self.dataLoading = NO;
[self.view setBackgroundColor:[ColorScheme mainBackground]];
+ [self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"messageCell"];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 500.0f;
self.messages = [NSMutableArray array];
- self.params = [NSMutableDictionary new];
self.refreshControl = [UIRefreshControl new];
[self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
if ([User isAuthenticated]) {
[User checkIsValid:^(BOOL success) {
if (success) {
- self.path = [APIClient feedUrl];
+ if ([self.path length] == 0) {
+ self.path = [APIClient feedUrl];
+ }
[self refreshData];
} else {
[User throwUnableToLogin:self];
@@ -86,7 +88,9 @@
}];
} else {
- self.path = [APIClient messagesUrl];
+ if ([self.path length] == 0) {
+ self.path = [APIClient messagesUrl];
+ }
[self refreshData];
}
}
@@ -111,14 +115,19 @@
return cell;
}
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if ([self.path isEqualToString:[APIClient threadUrl]])
- return;
- Message *msg = [self.messages objectAtIndex:indexPath.row];
- ThreadViewController *threadViewController = [[ThreadViewController alloc] init];
- [threadViewController setPath:[APIClient threadUrl]];
- [threadViewController setParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:msg.mid, @"mid", nil]];
- [self.navigationController pushViewController:threadViewController animated:NO];
+-(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]];
+ }
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView_ {