From c6cd3671deb881a658627ebe39ef4db2762a49b7 Mon Sep 17 00:00:00 2001 From: William Grant Date: Tue, 16 May 2023 16:08:42 +1000 Subject: [PATCH] fix: run expireUpdate handler on all messages and just return the model if there are no changes --- ts/receiver/dataMessage.ts | 12 +++++------- ts/util/expiringMessages.ts | 11 ++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 6a0e64870..272e7cbb0 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -243,13 +243,11 @@ export async function handleSwarmDataMessage( sentAt: sentAtTimestamp, }); - if (expireUpdate && !isEmpty(expireUpdate)) { - if (isSyncedMessage) { - // TODO handle sync messages expiring separately? - window.log.debug('WIP: Sync Message dropping'); - } else { - msgModel = handleExpireUpdate(convoToAddMessageTo, msgModel, expireUpdate); - } + if (isSyncedMessage) { + // TODO handle sync messages expiring separately? + window.log.debug('WIP: Sync Message dropping'); + } else { + msgModel = handleExpireUpdate(convoToAddMessageTo, msgModel, expireUpdate); } await handleSwarmMessage( diff --git a/ts/util/expiringMessages.ts b/ts/util/expiringMessages.ts index 17141087f..8aea9776e 100644 --- a/ts/util/expiringMessages.ts +++ b/ts/util/expiringMessages.ts @@ -22,8 +22,9 @@ export type DisappearingMessageType = typeof DisappearingMessageMode[number] | n export const DisappearingMessageConversationSetting = ['off', ...DisappearingMessageMode, 'legacy']; export type DisappearingMessageConversationType = typeof DisappearingMessageConversationSetting[number]; export const DEFAULT_TIMER_OPTION = { - PRIVATE_CONVERSATION: 86400, // 1 day - GROUP: 43200, // 12 hours + DELETE_AFTER_READ: 43200, // 12 hours + DELETE_AFTER_SEND: 86400, // 1 day + LEGACY: 86400, // 1 day }; export type DisappearingMessageUpdate = { @@ -353,8 +354,12 @@ export async function checkForExpireUpdate( export function handleExpireUpdate( converationModel: ConversationModel, messageModel: MessageModel, - expireUpdate: DisappearingMessageUpdate + expireUpdate?: DisappearingMessageUpdate ) { + if (!expireUpdate) { + return messageModel; + } + if (converationModel.isPublic()) { window.log.warn("updateExpireTimer() Disappearing messages aren't supported in communities"); return messageModel;