Improve handling of expireTimerVersion glare

This commit is contained in:
trevor-signal 2024-11-18 16:28:29 -05:00 committed by GitHub
parent b8ae50efd6
commit 512dcaad45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4679,32 +4679,37 @@ export class ConversationModel extends window.Backbone
expireTimer = undefined; expireTimer = undefined;
} }
const timerMatchesLocalValue =
this.get('expireTimer') === expireTimer ||
(!expireTimer && !this.get('expireTimer'));
const localVersion = this.getExpireTimerVersion();
const logId = const logId =
`updateExpirationTimer(${this.idForLogging()}, ` + `updateExpirationTimer(${this.idForLogging()}, ` +
`${expireTimer || 'disabled'}, version=${version || 0}) ` + `${expireTimer || 'disabled'}, version=${version || 0}) ` +
`source=${source ?? '?'} reason=${reason}`; `source=${source ?? '?'} localValue=${this.get('expireTimer')} ` +
`localVersion=${localVersion}, reason=${reason}`;
if (isSetByOther) { if (isSetByOther) {
const expireTimerVersion = this.getExpireTimerVersion();
if (version) { if (version) {
if (expireTimerVersion && version < expireTimerVersion) { if (localVersion && version < localVersion) {
log.warn( log.warn(`${logId}: not updating, local version is ${localVersion}`);
`${logId}: not updating, local version is ${expireTimerVersion}`
);
return; return;
} }
if (version === expireTimerVersion) {
log.warn(`${logId}: expire version glare`); if (version === localVersion) {
if (!timerMatchesLocalValue) {
log.warn(`${logId}: expire version glare`);
}
} else { } else {
this.set({ expireTimerVersion: version }); this.set({ expireTimerVersion: version });
log.info(`${logId}: updating expire version`); log.info(`${logId}: updating expire version`);
} }
} }
} }
if (
this.get('expireTimer') === expireTimer || if (timerMatchesLocalValue) {
(!expireTimer && !this.get('expireTimer'))
) {
return; return;
} }