From 055bec9d20331a0a5cd95bcd4038b6d4b2a6507e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 17 Mar 2022 18:19:06 +0300 Subject: Fix itemToScroll calculation --- Juick/ViewControllers/MessagesViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Juick') diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index aae1593..fb3f63b 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -87,8 +87,8 @@ NSString* const messageCellIdentifier = @"messageCell"; if (self.shouldScrollToUnreadOnRefresh) { NSInteger messagesCount = [self.messages count]; if (messagesCount > 0) { - NSInteger itemToScroll = [self.firstUnread integerValue] ? : self.messages.count - 1; - NSIndexPath *lastRow = [NSIndexPath indexPathForRow:MIN(itemToScroll, messagesCount - 1) inSection:0]; + NSInteger itemToScroll = MIN([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; -- cgit v1.2.3