From 9002b21a6b6c35081f70fd6ba610bfa28b35b032 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 7 Oct 2020 14:22:14 -0700 Subject: [PATCH] Minimize downstream effects of storage sync --- ts/models/conversations.ts | 7 ++++++- ts/services/storageRecordOps.ts | 15 +++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 0da0aa670..7ff9d5843 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -1230,6 +1230,9 @@ export class ConversationModel extends window.Backbone.Model< const isLocalAction = !fromSync && !viaStorageServiceSync; const ourConversationId = window.ConversationController.getOurConversationId(); + const currentMessageRequestState = this.get('messageRequestResponseType'); + const didResponseChange = response !== currentMessageRequestState; + // Apply message request response locally this.set({ messageRequestResponseType: response, @@ -1240,7 +1243,9 @@ export class ConversationModel extends window.Backbone.Model< this.unblock({ viaStorageServiceSync }); this.enableProfileSharing({ viaStorageServiceSync }); - await this.handleReadAndDownloadAttachments({ isLocalAction }); + if (didResponseChange) { + await this.handleReadAndDownloadAttachments({ isLocalAction }); + } if (isLocalAction) { if (this.isGroupV1() || this.isPrivate()) { diff --git a/ts/services/storageRecordOps.ts b/ts/services/storageRecordOps.ts index 6b96916c9..fe1d77828 100644 --- a/ts/services/storageRecordOps.ts +++ b/ts/services/storageRecordOps.ts @@ -457,12 +457,19 @@ export async function mergeGroupV2Record( updateConversation(conversation.attributes); + const isGroupNewToUs = !isNumber(conversation.get('revision')); const isFirstSync = !isNumber(window.storage.get('manifestVersion')); const dropInitialJoinMessage = isFirstSync; - waitThenMaybeUpdateGroup({ - conversation, - dropInitialJoinMessage, - }); + + // We don't need to update GroupV2 groups all the time. We fetch group state the first + // time we hear about these groups, from then on we rely on incoming messages or + // the user opening that conversation. + if (isGroupNewToUs) { + waitThenMaybeUpdateGroup({ + conversation, + dropInitialJoinMessage, + }); + } return hasPendingChanges; }