Merge pull request #395 from RyanRory/conversation-screen-update

Fix Conversation Screen Updating Bug
This commit is contained in:
Niels Andriesse 2021-04-21 08:48:03 +10:00 committed by GitHub
commit f09b02a2ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -196,6 +196,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) NSArray<id<ConversationViewItem>> *persistedViewItems;
@property (nonatomic) NSArray<TSOutgoingMessage *> *unsavedOutgoingMessages;
@property (nonatomic) BOOL hasUiDatabaseUpdatedExternally;
@end
#pragma mark -
@ -551,9 +553,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)uiDatabaseDidUpdateExternally:(NSNotification *)notification
{
OWSAssertIsOnMainThread();
// External database modifications (e.g. changes from another process such as the SAE)
// are "flushed" using touchDbAsync when the app re-enters the foreground.
// NSE will trigger this when we receive a new message from remote PN,
// the touchDbAsync will trigger uiDatabaseDidUpdate but with a notification
// that does NOT include the recent update from NSE.
// This flag let the uiDatabaseDidUpdate know it needs to expect more update
// than those in the notification.
_hasUiDatabaseUpdatedExternally = true;
}
- (void)uiDatabaseWillUpdate:(NSNotification *)notification
@ -571,10 +578,12 @@ NS_ASSUME_NONNULL_BEGIN
YapDatabaseAutoViewConnection *messageDatabaseView =
[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName];
OWSAssertDebug([messageDatabaseView isKindOfClass:[YapDatabaseAutoViewConnection class]]);
if (![messageDatabaseView hasChangesForGroup:self.thread.uniqueId inNotifications:notifications]) {
if (![messageDatabaseView hasChangesForGroup:self.thread.uniqueId inNotifications:notifications] && !_hasUiDatabaseUpdatedExternally) {
[self.delegate conversationViewModelDidUpdate:ConversationUpdate.minorUpdate];
return;
}
_hasUiDatabaseUpdatedExternally = false;
__block ConversationMessageMappingDiff *_Nullable diff = nil;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {