diff --git a/_locales/en/messages.json b/_locales/en/messages.json index bf2ae1305..7875fe164 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -179,9 +179,11 @@ "unblockToSend": "Unblock this contact to send a message.", "unblockGroupToSend": "This group is blocked. Unlock it if you would like to send a message.", "timer": "Timer", - "youChangedTheTimer": "You set the disappearing message timer to $time$", + "timerModeRead": "read", + "timerModeSent": "sent", + "youChangedTheTimer": "You have changed messages to disappear $time$ after they have been $mode$", "timerSetOnSync": "Updated disappearing message timer to $time$", - "theyChangedTheTimer": "$name$ set the disappearing message timer to $time$", + "theyChangedTheTimer": "$name$ has changed messages to disappear $time$ after they have been $mode$", "timerOption_0_seconds": "Off", "timerOption_5_seconds": "5 seconds", "timerOption_10_seconds": "10 seconds", diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index 7377d6a2a..fa6ee29d6 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -184,6 +184,7 @@ export function useMessageReactsPropsById(messageId?: string) { }); } +// TODO remove 10 seconds timer export function useTimerOptionsByMode(disappearingMessageMode?: string) { return useSelector((state: StateType) => { let options = state.timerOptions.timerOptions; @@ -192,6 +193,7 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) { case 'deleteAfterSend': return options.filter(option => { return ( + option.value === 10 || // 10 seconds (for testing) option.value === 43200 || // 12 hours option.value === 86400 || // 1 day option.value === 604800 || // 1 week @@ -201,6 +203,7 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) { case 'deleteAfterRead': return options.filter(option => { return ( + option.value === 10 || // 10 seconds (for testing) option.value === 300 || // 5 minutes option.value === 3600 || // 1 hour option.value === 43200 || // 12 hours diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 12408f67b..986c9d418 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1044,16 +1044,6 @@ export class ConversationModel extends Backbone.Model { expireTimer = 0; } - if (this.get('expireTimer') === expireTimer || (!expireTimer && !this.get('expireTimer'))) { - window.log.info(`WIP: This disappearing message setting is invalid`, { - id: this.idForLogging(), - expirationType, - expireTimer, - source, - }); - return; - } - const isOutgoing = Boolean(!receivedAt); source = source || UserUtils.getOurPubKeyStrFromCache(); @@ -1314,6 +1304,7 @@ export class ConversationModel extends Backbone.Model { hasErrors: Boolean(errors && errors.length), }); } + const oldUnreadNowReadAttrs = oldUnreadNowRead.map(m => m.attributes); if (oldUnreadNowReadAttrs?.length) { await Data.saveMessages(oldUnreadNowReadAttrs); diff --git a/ts/models/messageFactory.ts b/ts/models/messageFactory.ts index 6b8469b25..2ae78459a 100644 --- a/ts/models/messageFactory.ts +++ b/ts/models/messageFactory.ts @@ -35,8 +35,6 @@ export function createSwarmMessageSentFromUs(args: { const messageData: MessageAttributesOptionals = { ...getSharedAttributesForSwarmMessage(args), ...getSharedAttributesForOutgoingMessage(), - // TODO need to update this for delete after read - expirationStartTimestamp: Math.min(args.sentAt, Date.now()), }; return new MessageModel(messageData); @@ -80,6 +78,7 @@ function getSharedAttributesForPublicMessage({ isPublic: true, conversationId, messageHash: '', // we do not care of a messageHash for an opengroup message. we have serverId for that + // TODO do we need to worry about this? expirationStartTimestamp: undefined, }; } diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 5f30e6b77..61a06b714 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -16,7 +16,10 @@ import { ConversationTypeEnum, } from '../../models/conversationAttributes'; import { ReactionList } from '../../types/Reaction'; -import { DisappearingMessageConversationType } from '../../util/expiringMessages'; +import { + DisappearingMessageConversationType, + DisappearingMessageType, +} from '../../util/expiringMessages'; export type CallNotificationType = 'missed-call' | 'started-call' | 'answered-a-call'; export type PropsForCallNotification = { @@ -72,8 +75,8 @@ export type FindAndFormatContactType = { isMe: boolean; }; -// TODO Should this be updated? export type PropsForExpirationTimer = { + expirationType: DisappearingMessageConversationType; timespan: string; disabled: boolean; pubkey: string; @@ -194,6 +197,7 @@ export type PropsForMessageWithoutConvoProps = { messageHash?: string; isDeleted?: boolean; isUnread?: boolean; + expirationType?: DisappearingMessageType; expirationLength?: number; expirationTimestamp?: number | null; isExpired?: boolean; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 0037a81b1..08d59601b 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -1148,6 +1148,7 @@ export const getGenericReadableMessageSelectorProps = createSelector( 'convoId', 'direction', 'conversationType', + 'expirationType', 'expirationLength', 'expirationTimestamp', 'isExpired', diff --git a/ts/types/LocalizerKeys.ts b/ts/types/LocalizerKeys.ts index ef804fe18..3f39e22fc 100644 --- a/ts/types/LocalizerKeys.ts +++ b/ts/types/LocalizerKeys.ts @@ -179,6 +179,8 @@ export type LocalizerKeys = | 'unblockToSend' | 'unblockGroupToSend' | 'timer' + | 'timerModeRead' + | 'timerModeSent' | 'youChangedTheTimer' | 'timerSetOnSync' | 'theyChangedTheTimer'