MessageRequests: Only add events to timeline if value really changed

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2025-01-14 13:58:31 -06:00 committed by GitHub
parent c672eb7e95
commit 95bfc89f16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 13 deletions

View file

@ -2388,12 +2388,28 @@ export class ConversationModel extends window.Backbone
const isLocalAction = !fromSync && !viaStorageServiceSync; const isLocalAction = !fromSync && !viaStorageServiceSync;
const currentMessageRequestState = this.get('messageRequestResponseType'); const currentMessageRequestState = this.get('messageRequestResponseType');
const didResponseChange = response !== currentMessageRequestState; const hasSpam = (messageRequestValue: number | undefined): boolean => {
const wasPreviouslyAccepted = this.getAccepted(); 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 = const didUnblock =
response === messageRequestEnum.ACCEPT && this.isBlocked(); response === messageRequestEnum.ACCEPT && this.isBlocked();
const didResponseChange = response !== currentMessageRequestState;
const wasPreviouslyAccepted = this.getAccepted();
if (didResponseChange) { if (didResponseChange) {
if (response === messageRequestEnum.ACCEPT) { if (response === messageRequestEnum.ACCEPT) {
// Only add a message if the user unblocked this conversation, or took an // 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 || if (hasBlock(response) && didBlockChange) {
response === messageRequestEnum.BLOCK_AND_SPAM ||
response === messageRequestEnum.BLOCK_AND_DELETE
) {
drop( drop(
this.addMessageRequestResponseEventMessage( this.addMessageRequestResponseEventMessage(
MessageRequestResponseEvent.BLOCK MessageRequestResponseEvent.BLOCK
) )
); );
} }
if ( if (hasSpam(response) && didSpamChange) {
response === messageRequestEnum.SPAM ||
response === messageRequestEnum.BLOCK_AND_SPAM
) {
drop( drop(
this.addMessageRequestResponseEventMessage( this.addMessageRequestResponseEventMessage(
MessageRequestResponseEvent.SPAM MessageRequestResponseEvent.SPAM

View file

@ -2212,7 +2212,9 @@ async function upload({
// The sync job will check for conflicts and as part of that conflict // 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 // check if an item needs sync and doesn't match with the remote record
// it'll kick off another upload. // it'll kick off another upload.
setTimeout(runStorageServiceSyncJob); setTimeout(() =>
runStorageServiceSyncJob({ reason: `409 conflict backoff/${reason}` })
);
return; return;
} }
log.error(`${logId}/${version}: error`, Errors.toLogFormat(err)); log.error(`${logId}/${version}: error`, Errors.toLogFormat(err));