Stories: Start expiration on receipt

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2022-10-17 16:45:10 -07:00 committed by GitHub
parent 8f8cf98e3b
commit 8daac4ab8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -2646,6 +2646,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
!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)) {

View File

@ -1060,6 +1060,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;
@ -1075,6 +1079,7 @@ export function reducer(
hasAttachmentDownloaded ||
hasAttachmentFailed ||
hasBeenDeleted ||
hasExpirationChanged ||
hasSendStateChanged ||
readStatusChanged ||
reactionsChanged;