diff options
author | Vitaly Takmazov | 2019-03-25 16:07:22 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-25 16:07:22 +0300 |
commit | 72fbd1b82041082dfb25cfdf0f28db65fd1c878a (patch) | |
tree | da00ae2f01af038da435342ee7282fe8575c7e4d /Juick/ViewControllers/MessagesViewController.m | |
parent | 163a79e2aa4df23638686ca0608cdbaf6e6dad6f (diff) |
Scroll to reply from notification
Diffstat (limited to 'Juick/ViewControllers/MessagesViewController.m')
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index 57087d7..09e84ec 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -69,9 +69,11 @@ NSString* const messageCellIdentifier = @"messageCell"; [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:NO]; [self.tableView endUpdates]; [self.refreshControl endRefreshing]; - if (self.shouldScrollToBottomOnRefresh) { - NSIndexPath *lastRow = [NSIndexPath indexPathForRow:self.messages.count - 1 inSection:0]; + if (self.shouldScrollToUnreadOnRefresh) { + NSInteger itemToScroll = [self.firstUnread integerValue] || self.messages.count - 1; + NSIndexPath *lastRow = [NSIndexPath indexPathForRow:itemToScroll inSection:0]; [self.tableView scrollToRowAtIndexPath:lastRow atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + self.firstUnread = nil; } }]; } @@ -132,7 +134,7 @@ NSString* const messageCellIdentifier = @"messageCell"; -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Message *msg = [self.messages objectAtIndex:indexPath.row]; - [self viewThreadForMessage:msg mid:msg.mid]; + [self viewThreadForMessage:msg mid:msg.mid scrollTo:0]; } -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { @@ -154,13 +156,18 @@ NSString* const messageCellIdentifier = @"messageCell"; } } --(void) viewThreadForMessage:(Message *)msg mid:(NSNumber *)mid { +-(void) viewThreadForMessage:(Message *)msg mid:(NSNumber *)mid scrollTo:(NSNumber *)rid { ThreadViewController *threadVC = [AppDelegate threadViewController]; if (msg) { [threadVC setMessages:[@[msg] mutableCopy]]; } [threadVC setParams:@{@"mid": mid }]; - [threadVC setShouldScrollToBottomOnRefresh:NO]; + if (rid) { + [threadVC setFirstUnread:rid]; + [threadVC setShouldScrollToUnreadOnRefresh:YES]; + } else { + [threadVC setShouldScrollToUnreadOnRefresh:NO]; + } [self.navigationController pushViewController:threadVC animated:YES]; } |