diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 0c866b6ace..6015c2e718 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -2388,12 +2388,28 @@ export class ConversationModel extends window.Backbone const isLocalAction = !fromSync && !viaStorageServiceSync; const currentMessageRequestState = this.get('messageRequestResponseType'); - const didResponseChange = response !== currentMessageRequestState; - const wasPreviouslyAccepted = this.getAccepted(); - + const hasSpam = (messageRequestValue: number | undefined): boolean => { + return ( + messageRequestValue === messageRequestEnum.SPAM || + messageRequestValue === messageRequestEnum.BLOCK_AND_SPAM + ); + }; + const hasBlock = (messageRequestValue: number | undefined): boolean => { + return ( + messageRequestValue === messageRequestEnum.BLOCK || + messageRequestValue === messageRequestEnum.BLOCK_AND_SPAM || + messageRequestValue === messageRequestEnum.BLOCK_AND_DELETE + ); + }; + const didSpamChange = + hasSpam(currentMessageRequestState) !== hasSpam(response); + const didBlockChange = hasBlock(response) !== this.isBlocked(); const didUnblock = response === messageRequestEnum.ACCEPT && this.isBlocked(); + const didResponseChange = response !== currentMessageRequestState; + const wasPreviouslyAccepted = this.getAccepted(); + if (didResponseChange) { if (response === messageRequestEnum.ACCEPT) { // Only add a message if the user unblocked this conversation, or took an @@ -2408,21 +2424,15 @@ export class ConversationModel extends window.Backbone ); } } - if ( - response === messageRequestEnum.BLOCK || - response === messageRequestEnum.BLOCK_AND_SPAM || - response === messageRequestEnum.BLOCK_AND_DELETE - ) { + + if (hasBlock(response) && didBlockChange) { drop( this.addMessageRequestResponseEventMessage( MessageRequestResponseEvent.BLOCK ) ); } - if ( - response === messageRequestEnum.SPAM || - response === messageRequestEnum.BLOCK_AND_SPAM - ) { + if (hasSpam(response) && didSpamChange) { drop( this.addMessageRequestResponseEventMessage( MessageRequestResponseEvent.SPAM diff --git a/ts/services/storage.ts b/ts/services/storage.ts index 559cdb2abd..f503d831d8 100644 --- a/ts/services/storage.ts +++ b/ts/services/storage.ts @@ -2212,7 +2212,9 @@ async function upload({ // The sync job will check for conflicts and as part of that conflict // check if an item needs sync and doesn't match with the remote record // it'll kick off another upload. - setTimeout(runStorageServiceSyncJob); + setTimeout(() => + runStorageServiceSyncJob({ reason: `409 conflict backoff/${reason}` }) + ); return; } log.error(`${logId}/${version}: error`, Errors.toLogFormat(err));