From a484011acb4ad2dbe5ad734fa4aa34100848d008 Mon Sep 17 00:00:00 2001 From: William Grant Date: Thu, 28 Sep 2023 16:53:26 +1000 Subject: [PATCH] refactor: changetodisappearingmessageconversationtype to changetodisappearingconversationmode --- ts/models/message.ts | 8 ++++---- ts/receiver/queuedJob.ts | 8 ++++---- ts/session/sending/MessageSender.ts | 4 ++-- ts/session/sending/MessageSentHandler.ts | 8 ++------ ts/util/expiringMessages.ts | 4 ++-- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/ts/models/message.ts b/ts/models/message.ts index 4ce6e3feb..4229eb69c 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -91,7 +91,7 @@ import { roomHasBlindEnabled } from '../types/sqlSharedTypes'; import { ExpirationTimerOptions, setExpirationStartTimestamp, - changeToDisappearingMessageConversationType, + changeToDisappearingConversationMode, checkForExpireUpdateInContentMessage, updateMessageExpiryOnSwarm, } from '../util/expiringMessages'; @@ -267,7 +267,7 @@ export class MessageModel extends Backbone.Model { return ''; } - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( convo, expireTimerUpdate?.expirationType, expireTimer @@ -334,7 +334,7 @@ export class MessageModel extends Backbone.Model { } const { expireTimer, fromSync, source } = timerUpdate; - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( convo, timerUpdate?.expirationType || 'unknown', expireTimer || 0 @@ -1111,7 +1111,7 @@ export class MessageModel extends Backbone.Model { const expireTimer = this.get('expireTimer'); if (canBeDeleteAfterRead && expirationType && expireTimer > 0) { - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( convo, expirationType, expireTimer diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index f17ca966c..b573ef73e 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -15,7 +15,7 @@ import { showMessageRequestBannerOutsideRedux } from '../state/ducks/userConfig' import { getHideMessageRequestBannerOutsideRedux } from '../state/selectors/userConfig'; import { GoogleChrome } from '../util'; import { - changeToDisappearingMessageConversationType, + changeToDisappearingConversationMode, setExpirationStartTimestamp, } from '../util/expiringMessages'; import { LinkPreviews } from '../util/linkPreviews'; @@ -347,7 +347,7 @@ async function markConvoAsReadIfOutgoingMessage( expireTimer > 0 && Boolean(message.get('expirationStartTimestamp')) === false ) { - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( conversation, expirationType, expireTimer @@ -397,7 +397,7 @@ export async function handleMessageJob( messageModel.get('expireTimer') > 0 && Boolean(messageModel.get('expirationStartTimestamp')) === false ) { - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( conversation, messageModel.get('expirationType'), messageModel.get('expireTimer') @@ -436,7 +436,7 @@ export async function handleMessageJob( } const expireTimerUpdate = expirationTimerUpdate?.expireTimer || 0; - const expirationTypeUpdate = changeToDisappearingMessageConversationType( + const expirationTypeUpdate = changeToDisappearingConversationMode( conversation, expirationTimerUpdate?.expirationType, expireTimerUpdate diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index e264c5bc9..cc3c99b01 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -38,7 +38,7 @@ import { ed25519Str } from '../onions/onionPath'; import { PubKey } from '../types'; import { RawMessage } from '../types/RawMessage'; import { - changeToDisappearingMessageConversationType, + changeToDisappearingConversationMode, updateMessageExpiryOnSwarm, } from '../../util/expiringMessages'; @@ -172,7 +172,7 @@ async function send( // a message has started to disappear foundMessage.get('expirationStartTimestamp') ) { - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( convo, expirationType, expireTimer diff --git a/ts/session/sending/MessageSentHandler.ts b/ts/session/sending/MessageSentHandler.ts index 06ac631b3..55fa69614 100644 --- a/ts/session/sending/MessageSentHandler.ts +++ b/ts/session/sending/MessageSentHandler.ts @@ -2,7 +2,7 @@ import _ from 'lodash'; import { Data } from '../../data/data'; import { SignalService } from '../../protobuf'; import { - changeToDisappearingMessageConversationType, + changeToDisappearingConversationMode, setExpirationStartTimestamp, } from '../../util/expiringMessages'; import { PnServer } from '../apis/push_notification_api'; @@ -140,11 +140,7 @@ async function handleMessageSentSuccess( expireTimer > 0 && Boolean(fetchedMessage.get('expirationStartTimestamp')) === false ) { - const expirationMode = changeToDisappearingMessageConversationType( - convo, - expirationType, - expireTimer - ); + const expirationMode = changeToDisappearingConversationMode(convo, expirationType, expireTimer); // NOTE starting disappearing messages timer for all outbound messages if (expirationMode !== 'off') { diff --git a/ts/util/expiringMessages.ts b/ts/util/expiringMessages.ts index 1e282c20b..d2c6e5228 100644 --- a/ts/util/expiringMessages.ts +++ b/ts/util/expiringMessages.ts @@ -352,7 +352,7 @@ export function changeToDisappearingMessageType( * @param expireTimer * @returns */ -export function changeToDisappearingMessageConversationType( +export function changeToDisappearingConversationMode( convo: ConversationModel, expirationType?: DisappearingMessageType, expireTimer?: number @@ -437,7 +437,7 @@ export async function checkForExpireUpdateInContentMessage( : content.expirationTimer; // NOTE we don't use the expirationType directly from the Content Message because we need to resolve it to the correct convo type first in case it is legacy or has errors - const expirationMode = changeToDisappearingMessageConversationType( + const expirationMode = changeToDisappearingConversationMode( convoToUpdate, DisappearingMessageMode[content.expirationType], expirationTimer