From dc781650439ece053d781db26ce0d05dd2b333f1 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Tue, 29 Jun 2021 16:05:56 -0500 Subject: [PATCH] Fix types when creating ephemeral messages for DOE and reactions --- ts/models/conversations.ts | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 17f16d93bcff..262e6b890b9a 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -3184,7 +3184,9 @@ export class ConversationModel extends window.Backbone timestamp ); - const attributes = ({ + // We are only creating this model so we can use its sync message + // sending functionality. It will not be saved to the database. + const message = new window.Whisper.Message({ id: window.getGuid(), type: 'outgoing', conversationId: this.get('id'), @@ -3193,16 +3195,9 @@ export class ConversationModel extends window.Backbone received_at_ms: timestamp, recipients, deletedForEveryoneTimestamp: targetTimestamp, - // TODO: DESKTOP-722 - } as unknown) as typeof window.Whisper.MessageAttributesType; - - if (isDirectConversation(this.attributes)) { - attributes.destination = destination; - } - - // We are only creating this model so we can use its sync message - // sending functionality. It will not be saved to the database. - const message = new window.Whisper.Message(attributes); + timestamp, + ...(isDirectConversation(this.attributes) ? { destination } : {}), + }); // We're offline! if (!window.textsecure.messaging) { @@ -3318,7 +3313,9 @@ export class ConversationModel extends window.Backbone const expireTimer = this.get('expireTimer'); - const attributes = ({ + // We are only creating this model so we can use its sync message + // sending functionality. It will not be saved to the database. + const message = new window.Whisper.Message({ id: window.getGuid(), type: 'outgoing', conversationId: this.get('id'), @@ -3327,16 +3324,9 @@ export class ConversationModel extends window.Backbone received_at_ms: timestamp, recipients, reaction: outgoingReaction, - // TODO: DESKTOP-722 - } as unknown) as typeof window.Whisper.MessageAttributesType; - - if (isDirectConversation(this.attributes)) { - attributes.destination = destination; - } - - // We are only creating this model so we can use its sync message - // sending functionality. It will not be saved to the database. - const message = new window.Whisper.Message(attributes); + timestamp, + ...(isDirectConversation(this.attributes) ? { destination } : {}), + }); // This is to ensure that the functions in send() and sendSyncMessage() don't save // anything to the database.