From 6f78de0ed33a3c6b9460e65484ab37c5f842f1f6 Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 9 Oct 2023 11:44:11 +1100 Subject: [PATCH] feat: made ExpirationTimerUpdate type --- ts/models/messageType.ts | 21 +++------------------ ts/util/expiringMessages.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ts/models/messageType.ts b/ts/models/messageType.ts index 002ff81e8..29527a69d 100644 --- a/ts/models/messageType.ts +++ b/ts/models/messageType.ts @@ -8,7 +8,7 @@ import { import { AttachmentTypeWithPath } from '../types/Attachment'; import { Reaction, ReactionList, SortedReactionList } from '../types/Reaction'; import { READ_MESSAGE_STATE } from './conversationAttributes'; -import { DisappearingMessageType } from '../util/expiringMessages'; +import { DisappearingMessageType, ExpirationTimerUpdate } from '../util/expiringMessages'; export type MessageModelType = 'incoming' | 'outgoing'; @@ -30,14 +30,7 @@ export interface MessageAttributes { expireTimer: number; expirationStartTimestamp: number; expires_at?: number; - // NOTE this is used for conversation setting - expirationTimerUpdate?: { - expirationType: DisappearingMessageType; - expireTimer: number; - lastDisappearingMessageChangeTimestamp: number; - source: string; - fromSync?: boolean; - }; + expirationTimerUpdate?: ExpirationTimerUpdate; read_by: Array; // we actually only care about the length of this. values are not used for anything type: MessageModelType; group_update?: MessageGroupUpdate; @@ -177,15 +170,7 @@ export interface MessageAttributesOptionals { expireTimer?: number; expirationStartTimestamp?: number; expires_at?: number; - // TODO legacy messages support will be removed in a future release - // types will no longer have an undefined option - expirationTimerUpdate?: { - expirationType: DisappearingMessageType | undefined; - expireTimer: number; - lastDisappearingMessageChangeTimestamp: number | undefined; - source: string; - fromSync?: boolean; - }; + expirationTimerUpdate?: ExpirationTimerUpdate; read_by?: Array; // we actually only care about the length of this. values are not used for anything type: MessageModelType; group_update?: MessageGroupUpdate; diff --git a/ts/util/expiringMessages.ts b/ts/util/expiringMessages.ts index 5ff20a883..095df5552 100644 --- a/ts/util/expiringMessages.ts +++ b/ts/util/expiringMessages.ts @@ -37,6 +37,18 @@ export const DEFAULT_TIMER_OPTION = { LEGACY: 86400, // 1 day }; +// TODO legacy messages support will be removed in a future release +// expirationType and lastDisappearingMessageChangeTimestamp will no longer have an undefined option +/** Used for setting disappearing messages in conversations */ +export type ExpirationTimerUpdate = { + expirationType: DisappearingMessageType | undefined; + expireTimer: number; + lastDisappearingMessageChangeTimestamp: number | undefined; + source: string; + /** updated setting from another device */ + fromSync?: boolean; +}; + export type DisappearingMessageUpdate = { expirationType: DisappearingMessageType; expirationTimer: number;