From 8a6f30518aea67b01c40dd265a41c65ffc2c6b37 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 13 Dec 2018 13:25:55 -0500 Subject: [PATCH 1/3] Auto-extend conversation load window size. --- .../ConversationViewController.m | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 22f302610..8c2e21bc4 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1123,6 +1123,28 @@ typedef enum : NSUInteger { [self updateBackButtonUnreadCount]; [self autoLoadMoreIfNecessary]; + if (!self.viewHasEverAppeared) { + // Now that we're using a "minimal" initial load window, + // try to increase the load window a moment after we've + // settled into the view. + __weak ConversationViewController *weakSelf = self; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC / 2)), dispatch_get_main_queue(), ^{ + ConversationViewController *strongSelf = weakSelf; + if (!strongSelf) { + return; + } + + BOOL isMainAppAndActive = CurrentAppContext().isMainAppAndActive; + if (strongSelf.isUserScrolling || !strongSelf.isViewVisible || !isMainAppAndActive) { + return; + } + if (!strongSelf.conversationViewModel.canLoadMoreItems) { + return; + } + [strongSelf.conversationViewModel loadAnotherPageOfMessages]; + }); + } + self.conversationViewModel.focusMessageIdOnOpen = nil; self.isViewCompletelyAppeared = YES; From 6797d43510e54a7ef224bd56adcad41460997116 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 13 Dec 2018 13:29:32 -0500 Subject: [PATCH 2/3] Auto-extend conversation load window size. --- .../ConversationView/ConversationViewController.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 8c2e21bc4..5be61d02b 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1134,6 +1134,10 @@ typedef enum : NSUInteger { return; } + // Re-enable prefetching. + strongSelf.collectionView.prefetchingEnabled = YES; + + // Try to auto-extend the load window. BOOL isMainAppAndActive = CurrentAppContext().isMainAppAndActive; if (strongSelf.isUserScrolling || !strongSelf.isViewVisible || !isMainAppAndActive) { return; From 9c46ce86625fcd76247bb99b752322e50d65ddfa Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 13 Dec 2018 14:34:08 -0500 Subject: [PATCH 3/3] Re-enable prefetching a bit sooner. --- .../ConversationView/ConversationViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 5be61d02b..6a07dff52 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1124,6 +1124,9 @@ typedef enum : NSUInteger { [self autoLoadMoreIfNecessary]; if (!self.viewHasEverAppeared) { + // Re-enable prefetching. + self.collectionView.prefetchingEnabled = YES; + // Now that we're using a "minimal" initial load window, // try to increase the load window a moment after we've // settled into the view. @@ -1134,9 +1137,6 @@ typedef enum : NSUInteger { return; } - // Re-enable prefetching. - strongSelf.collectionView.prefetchingEnabled = YES; - // Try to auto-extend the load window. BOOL isMainAppAndActive = CurrentAppContext().isMainAppAndActive; if (strongSelf.isUserScrolling || !strongSelf.isViewVisible || !isMainAppAndActive) {