From 58f0012f141f5abff0dbb10d3f4b8efc2931dbff Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 17 Oct 2022 16:30:03 -0700 Subject: [PATCH] Stories: Start expiration on receipt --- ts/models/messages.ts | 6 ++++++ ts/state/ducks/stories.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 441527878..3be64fd7a 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -2646,6 +2646,12 @@ export class MessageModel extends window.Backbone.Model { !isExpirationTimerUpdate(dataMessage) ) { message.set({ expireTimer: dataMessage.expireTimer }); + if (isStory(message.attributes)) { + log.info(`${idLog}: Starting story expiration`); + message.set({ + expirationStartTimestamp: dataMessage.timestamp, + }); + } } if (!hasGroupV2Prop && !isStory(message.attributes)) { diff --git a/ts/state/ducks/stories.ts b/ts/state/ducks/stories.ts index 16bd3648f..5c433bf1d 100644 --- a/ts/state/ducks/stories.ts +++ b/ts/state/ducks/stories.ts @@ -1222,6 +1222,10 @@ export function reducer( isDownloaded(newStory.attachment); const hasAttachmentFailed = hasFailed(newStory.attachment) && !hasFailed(prevStory.attachment); + const hasExpirationChanged = + (newStory.expirationStartTimestamp && + !prevStory.expirationStartTimestamp) || + (newStory.expireTimer && !prevStory.expireTimer); const readStatusChanged = prevStory.readStatus !== newStory.readStatus; const reactionsChanged = prevStory.reactions?.length !== newStory.reactions?.length; @@ -1237,6 +1241,7 @@ export function reducer( hasAttachmentDownloaded || hasAttachmentFailed || hasBeenDeleted || + hasExpirationChanged || hasSendStateChanged || readStatusChanged || reactionsChanged;