From 777584945d09e2fffc0816dc817035ad601dd0e9 Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 2 Oct 2023 14:42:16 +1100 Subject: [PATCH] refactor: replaced get expireTimer calls with getExpireTimer --- ts/models/conversation.ts | 2 +- ts/models/message.ts | 16 ++++++++-------- ts/receiver/configMessage.ts | 2 +- ts/receiver/queuedJob.ts | 6 +++--- ts/session/sending/MessageSender.ts | 2 +- ts/session/sending/MessageSentHandler.ts | 4 ++-- ts/util/expiringMessages.ts | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 3724055f9..09e18ac5f 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1810,7 +1810,7 @@ export class ConversationModel extends Backbone.Model { timestamp: sentAt, attachments, expirationType: message.getExpirationType(), - expireTimer: message.get('expireTimer'), + expireTimer: message.getExpireTimer(), preview: preview ? [preview] : [], quote, lokiProfile: UserUtils.getOurProfile(), diff --git a/ts/models/message.ts b/ts/models/message.ts index 4ba899752..5d3e8e84d 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -295,8 +295,8 @@ export class MessageModel extends Backbone.Model { public getPropsForExpiringMessage(): PropsForExpiringMessage { const expirationType = this.getExpirationType(); - const expirationLength = this.get('expireTimer') - ? this.get('expireTimer') * DURATION.SECONDS + const expirationLength = this.getExpireTimer() + ? this.getExpireTimer() * DURATION.SECONDS : null; const expireTimerStart = this.get('expirationStartTimestamp') || null; @@ -518,7 +518,7 @@ export class MessageModel extends Backbone.Model { public getPropsForMessage(): PropsForMessageWithoutConvoProps { const sender = this.getSource(); const expirationType = this.getExpirationType(); - const expirationLength = this.get('expireTimer') * DURATION.SECONDS; + const expirationLength = this.getExpireTimer() * DURATION.SECONDS; const expireTimerStart = this.get('expirationStartTimestamp'); const expirationTimestamp = expirationType && expireTimerStart && expirationLength @@ -882,7 +882,7 @@ export class MessageModel extends Backbone.Model { identifier: this.id, body, timestamp, - expireTimer: this.get('expireTimer'), + expireTimer: this.getExpireTimer(), attachments, preview: preview ? [preview] : [], reacts: this.get('reacts'), @@ -1108,7 +1108,7 @@ export class MessageModel extends Backbone.Model { const convo = this.getConversation(); const canBeDeleteAfterRead = convo && !convo.isMe() && convo.isPrivate(); const expirationType = this.getExpirationType(); - const expireTimer = this.get('expireTimer'); + const expireTimer = this.getExpireTimer(); if (canBeDeleteAfterRead && expirationType && expireTimer > 0) { const expirationMode = changeToDisappearingConversationMode( @@ -1137,7 +1137,7 @@ export class MessageModel extends Backbone.Model { } public isExpiring() { - return this.get('expireTimer') && this.get('expirationStartTimestamp'); + return this.getExpireTimer() && this.get('expirationStartTimestamp'); } public isExpired() { @@ -1153,7 +1153,7 @@ export class MessageModel extends Backbone.Model { if (!start) { return Infinity; } - const delta = this.get('expireTimer') * 1000; + const delta = this.getExpireTimer() * 1000; let msFromNow = start + delta - now; if (msFromNow < 0) { msFromNow = 0; @@ -1164,7 +1164,7 @@ export class MessageModel extends Backbone.Model { public async setToExpire() { if (this.isExpiring() && !this.get('expires_at')) { const start = this.get('expirationStartTimestamp'); - const delta = this.get('expireTimer') * 1000; + const delta = this.getExpireTimer() * 1000; if (!start) { return; } diff --git a/ts/receiver/configMessage.ts b/ts/receiver/configMessage.ts index c8a9ab88d..5bec42bfc 100644 --- a/ts/receiver/configMessage.ts +++ b/ts/receiver/configMessage.ts @@ -710,7 +710,7 @@ async function applyConvoVolatileUpdateFromWrapper( Boolean( m.getExpirationType() && m.getExpirationType() !== 'deleteAfterSend' && - m.get('expireTimer') > 0 + m.getExpireTimer() > 0 ) ) .map(m => m.get('messageHash')) diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index 4adf072aa..53254e50e 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -340,7 +340,7 @@ async function markConvoAsReadIfOutgoingMessage( const sentAt = message.get('sent_at') || message.get('serverTimestamp'); if (sentAt) { const expirationType = message.getExpirationType(); - const expireTimer = message.get('expireTimer'); + const expireTimer = message.getExpireTimer(); // NOTE starting disappearing messages timer for all outbound messages if ( expirationType && @@ -394,13 +394,13 @@ export async function handleMessageJob( // NOTE we handle incoming disappear after send messages and sync messages here if ( conversation && - messageModel.get('expireTimer') > 0 && + messageModel.getExpireTimer() > 0 && Boolean(messageModel.get('expirationStartTimestamp')) === false ) { const expirationMode = changeToDisappearingConversationMode( conversation, messageModel.getExpirationType(), - messageModel.get('expireTimer') + messageModel.getExpireTimer() ); // TODO legacy messages support will be removed in a future release diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index 3afa08c45..d988d581d 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -162,7 +162,7 @@ async function send( if (foundMessage) { await foundMessage.updateMessageHash(messageSendHash); const convo = foundMessage.getConversation(); - const expireTimer = foundMessage.get('expireTimer'); + const expireTimer = foundMessage.getExpireTimer(); const expirationType = foundMessage.getExpirationType(); if ( diff --git a/ts/session/sending/MessageSentHandler.ts b/ts/session/sending/MessageSentHandler.ts index fdffe2b7a..fed61a363 100644 --- a/ts/session/sending/MessageSentHandler.ts +++ b/ts/session/sending/MessageSentHandler.ts @@ -131,7 +131,7 @@ async function handleMessageSentSuccess( }); const convo = fetchedMessage.getConversation(); - const expireTimer = fetchedMessage.get('expireTimer'); + const expireTimer = fetchedMessage.getExpireTimer(); const expirationType = fetchedMessage.getExpirationType(); if ( @@ -188,7 +188,7 @@ async function handleMessageSentFailure( }); // Disappeared messages that fail to send should not disappear - if (fetchedMessage.getExpirationType() && fetchedMessage.get('expireTimer') > 0) { + if (fetchedMessage.getExpirationType() && fetchedMessage.getExpireTimer() > 0) { fetchedMessage.set({ expirationStartTimestamp: undefined, }); diff --git a/ts/util/expiringMessages.ts b/ts/util/expiringMessages.ts index 88374d58b..ea97f0644 100644 --- a/ts/util/expiringMessages.ts +++ b/ts/util/expiringMessages.ts @@ -646,7 +646,7 @@ export async function updateMessageExpiryOnSwarm( window.log.debug(`WIP: [updateMessageExpiryOnSwarm] called from: ${callLocation} `); } - if (!message.getExpirationType() || !message.get('expireTimer')) { + if (!message.getExpirationType() || !message.getExpireTimer()) { window.log.debug( `WIP: [updateMessageExpiryOnSwarm] Message ${message.get( 'messageHash' @@ -667,7 +667,7 @@ export async function updateMessageExpiryOnSwarm( const newTTL = await expireMessageOnSnode({ messageHash, - expireTimer: message.get('expireTimer') * 1000, + expireTimer: message.getExpireTimer() * 1000, shorten: true, }); const expiresAt = message.get('expires_at');