MessageRequests: Only add events to timeline if value really changed

This commit is contained in:
Scott Nonnenberg 2025-01-15 01:48:39 +10:00 committed by GitHub
parent 16bbcc2c50
commit 7dbe57084b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 13 deletions

View file

@ -2390,12 +2390,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
@ -2410,21 +2426,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

View file

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