Minimize downstream effects of storage sync

This commit is contained in:
Scott Nonnenberg 2020-10-07 14:22:14 -07:00 committed by Josh Perez
parent b914b59969
commit 9002b21a6b
2 changed files with 17 additions and 5 deletions

View file

@ -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()) {

View file

@ -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;
}