From d9d5131e5f5a4510f7214bf62b2eaf8e60cc90bf Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 26 Jun 2018 14:40:53 -0600 Subject: [PATCH] FIX: obscured searchbar upon returning When navigating back from a conversation, we could be scrolled down a ways. Since the search bar lives in the inbox table view, we need to make sure the inbox table view is scrolled all the way up to keep the search bar visible. // FREEBIE --- .../HomeView/HomeViewController.m | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 6844a55fa..ed6e1e75d 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -529,18 +529,24 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations self.isViewVisible = YES; - // When returning to home view, try to ensure that the "last" thread is still - // visible. The threads often change ordering while in conversation view due - // to incoming & outgoing messages. - if (self.lastThread) { + BOOL isShowingSearchResults = !self.searchResultsController.view.hidden; + if (isShowingSearchResults) { + OWSAssert(self.searchBar.text.ows_stripped.length > 0); + self.tableView.contentOffset = CGPointZero; + } else if (self.lastThread) { + OWSAssert(self.searchBar.text.ows_stripped.length == 0); + + // When returning to home view, try to ensure that the "last" thread is still + // visible. The threads often change ordering while in conversation view due + // to incoming & outgoing messages. __block NSIndexPath *indexPathOfLastThread = nil; [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { indexPathOfLastThread = - [[transaction extension:TSThreadDatabaseViewExtensionName] indexPathForKey:self.lastThread.uniqueId - inCollection:[TSThread collection] - withMappings:self.threadMappings]; + [[transaction extension:TSThreadDatabaseViewExtensionName] indexPathForKey:self.lastThread.uniqueId + inCollection:[TSThread collection] + withMappings:self.threadMappings]; }]; - + if (indexPathOfLastThread) { [self.tableView scrollToRowAtIndexPath:indexPathOfLastThread atScrollPosition:UITableViewScrollPositionNone