Stories: Start expiration on receipt

This commit is contained in:
Scott Nonnenberg 2022-10-17 16:30:03 -07:00 committed by GitHub
parent d03b53d47e
commit 58f0012f14
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) !isExpirationTimerUpdate(dataMessage)
) { ) {
message.set({ expireTimer: dataMessage.expireTimer }); 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)) { if (!hasGroupV2Prop && !isStory(message.attributes)) {

View file

@ -1222,6 +1222,10 @@ export function reducer(
isDownloaded(newStory.attachment); isDownloaded(newStory.attachment);
const hasAttachmentFailed = const hasAttachmentFailed =
hasFailed(newStory.attachment) && !hasFailed(prevStory.attachment); hasFailed(newStory.attachment) && !hasFailed(prevStory.attachment);
const hasExpirationChanged =
(newStory.expirationStartTimestamp &&
!prevStory.expirationStartTimestamp) ||
(newStory.expireTimer && !prevStory.expireTimer);
const readStatusChanged = prevStory.readStatus !== newStory.readStatus; const readStatusChanged = prevStory.readStatus !== newStory.readStatus;
const reactionsChanged = const reactionsChanged =
prevStory.reactions?.length !== newStory.reactions?.length; prevStory.reactions?.length !== newStory.reactions?.length;
@ -1237,6 +1241,7 @@ export function reducer(
hasAttachmentDownloaded || hasAttachmentDownloaded ||
hasAttachmentFailed || hasAttachmentFailed ||
hasBeenDeleted || hasBeenDeleted ||
hasExpirationChanged ||
hasSendStateChanged || hasSendStateChanged ||
readStatusChanged || readStatusChanged ||
reactionsChanged; reactionsChanged;