From a37c8eaf132b157e845781bdd937e0f6df058812 Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 18 Oct 2023 13:50:02 +1100 Subject: [PATCH] fix: merge now returns good hashes we calc the latestEnvelopeTimestamp and use for disappearAfterRead --- ts/models/conversation.ts | 1 + ts/receiver/configMessage.ts | 9 ++++++--- ts/session/disappearing_messages/index.ts | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 70f6cdc74..527d19549 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -934,6 +934,7 @@ export class ConversationModel extends Backbone.Model { window.log.debug( `[updateExpireTimer] We dont send an ExpireTimerUpdate because this was a remote change receivedAt: ${receivedAt} fromSync: ${fromSync} for ${this.id}` ); + if (!message.getExpirationStartTimestamp()) { const canBeDeleteAfterSend = this.isMe() || this.isGroup(); if ( diff --git a/ts/receiver/configMessage.ts b/ts/receiver/configMessage.ts index 735fee387..11a4b2847 100644 --- a/ts/receiver/configMessage.ts +++ b/ts/receiver/configMessage.ts @@ -117,13 +117,16 @@ async function mergeConfigsWithIncomingUpdates( } } - const mergedCount = await GenericWrapperActions.merge(variant, toMerge); + const hashesMerged = await GenericWrapperActions.merge(variant, toMerge); const needsPush = await GenericWrapperActions.needsPush(variant); const needsDump = await GenericWrapperActions.needsDump(variant); - const latestEnvelopeTimestamp = Math.max(...sameVariant.map(m => m.envelopeTimestamp)); + const mergedTimestamps = sameVariant + .filter(m => hashesMerged.includes(m.messageHash)) + .map(m => m.envelopeTimestamp); + const latestEnvelopeTimestamp = Math.max(...mergedTimestamps); window.log.debug( - `${variant}: "${publicKey}" needsPush:${needsPush} needsDump:${needsDump}; mergedCount:${mergedCount} ` + `${variant}: "${publicKey}" needsPush:${needsPush} needsDump:${needsDump}; mergedCount:${hashesMerged.length}` ); if (window.sessionFeatureFlags.debug.debugLibsessionDumps) { diff --git a/ts/session/disappearing_messages/index.ts b/ts/session/disappearing_messages/index.ts index 97cc2a2bc..fc3336600 100644 --- a/ts/session/disappearing_messages/index.ts +++ b/ts/session/disappearing_messages/index.ts @@ -157,7 +157,11 @@ function setExpirationStartTimestamp( let expirationStartTimestamp: number | undefined = GetNetworkTime.getNowWithNetworkOffset(); if (callLocation) { - // window.log.debug(`[setExpirationStartTimestamp] called from: ${callLocation} ${messageId ? `messageId: ${messageId} ` : ''}`); + // window.log.debug( + // `[setExpirationStartTimestamp] called from: ${callLocation} ${ + // messageId ? `messageId: ${messageId} ` : '' + // }` + // ); } // TODO legacy messages support will be removed in a future release