diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index ece692249e..0da274ab55 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2825,9 +2825,8 @@ typedef enum : NSUInteger { // so rebuild everything. This is expensive and usually isn't necessary, but // there's no alternative. // - // There's no need to do this when app is in the background or this view isn't - // visible. We will resetMappings when the app re-enters the foreground or this - // view becomes visible. + // We don't need to do this if we're not observing db modifications since we'll + // do it when we resume. [self resetMappings]; } } @@ -4170,9 +4169,14 @@ typedef enum : NSUInteger { if (hasAddedNewItems) { NSIndexPath *_Nullable indexPathToShow = [self firstIndexPathAtViewHorizonTimestamp]; if (indexPathToShow) { + // The goal is to show _both_ the last item before the "view horizon" and the + // first item after the "view horizon". We can't do "top on first item after" + // or "bottom on last item before" or we won't see the other. Unfortunately, + // this gets tricky if either is huge. The largest cells are oversize text, + // which should be rare. Other cells are considerably smaller than a screenful. [self.collectionView scrollToItemAtIndexPath:indexPathToShow atScrollPosition:UICollectionViewScrollPositionCenteredVertically - animated:YES]; + animated:NO]; } } self.viewHorizonTimestamp = nil; @@ -4327,9 +4331,10 @@ typedef enum : NSUInteger { // made in another process (e.g. the SAE) from showing up in other processes. // There's a simple workaround: a trivial write to the database flushes changes // made from other processes. - [self.editingDatabaseConnection setObject:[NSUUID UUID].UUIDString - forKey:@"conversation_view_noop_mod" - inCollection:@"temp"]; + [self.editingDatabaseConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [transaction setObject:[NSUUID UUID].UUIDString forKey:@"conversation_view_noop_mod" inCollection:@"temp"]; + l + }]; } #pragma mark - ConversationCollectionViewDelegate diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index 47dc05d133..0943158d2e 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -935,6 +935,9 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; // External database modifications can't be converted into incremental updates, // so rebuild everything. This is expensive and usually isn't necessary, but // there's no alternative. + // + // We don't need to do this if we're not observing db modifications since we'll + // do it when we resume. [self resetMappings]; } } diff --git a/SignalMessaging/Views/ThreadViewHelper.m b/SignalMessaging/Views/ThreadViewHelper.m index b12c7b5752..c466b60ea0 100644 --- a/SignalMessaging/Views/ThreadViewHelper.m +++ b/SignalMessaging/Views/ThreadViewHelper.m @@ -133,6 +133,9 @@ NS_ASSUME_NONNULL_BEGIN // External database modifications can't be converted into incremental updates, // so rebuild everything. This is expensive and usually isn't necessary, but // there's no alternative. + // + // We don't need to do this if we're not observing db modifications since we'll + // do it when we resume. [self.uiDatabaseConnection beginLongLivedReadTransaction]; [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.threadMappings updateWithTransaction:transaction];