From 3abacb25ce5b6e3f274017adc1127d30daaaeabd Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 31 May 2023 11:14:38 -0700 Subject: [PATCH] Clear typing indicator after receiving edits --- ts/background.ts | 2 ++ ts/messageModifiers/Edits.ts | 1 + ts/util/handleEditMessage.ts | 7 +++++-- ts/util/sendEditedMessage.ts | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index b7ba0aede..5d2eef108 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -2589,6 +2589,7 @@ export async function startApp(): Promise { const editAttributes: EditAttributesType = { conversationId: message.attributes.conversationId, fromId: fromConversation.id, + fromDevice: data.sourceDevice ?? 1, message: copyDataMessageIntoMessage(data.message, message.attributes), targetSentTimestamp: editedMessageTimestamp, }; @@ -2912,6 +2913,7 @@ export async function startApp(): Promise { const editAttributes: EditAttributesType = { conversationId: message.attributes.conversationId, fromId: window.ConversationController.getOurConversationIdOrThrow(), + fromDevice: window.storage.user.getDeviceId() ?? 1, message: copyDataMessageIntoMessage(data.message, message.attributes), targetSentTimestamp: editedMessageTimestamp, }; diff --git a/ts/messageModifiers/Edits.ts b/ts/messageModifiers/Edits.ts index 21e3a61cb..df2ddb26c 100644 --- a/ts/messageModifiers/Edits.ts +++ b/ts/messageModifiers/Edits.ts @@ -14,6 +14,7 @@ import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp'; export type EditAttributesType = { conversationId: string; fromId: string; + fromDevice: number; message: MessageAttributesType; targetSentTimestamp: number; }; diff --git a/ts/util/handleEditMessage.ts b/ts/util/handleEditMessage.ts index b28ca1ea6..b1fa0c818 100644 --- a/ts/util/handleEditMessage.ts +++ b/ts/util/handleEditMessage.ts @@ -272,9 +272,12 @@ export async function handleEditMessage( ); drop(mainMessageModel.getConversation()?.updateLastMessage()); - - // Update notifications if (conversation) { + // Clear typing indicator + const typingToken = `${editAttributes.fromId}.${editAttributes.fromDevice}`; + conversation.clearContactTypingTimer(typingToken); + + // Update notifications if (await shouldReplyNotifyUser(mainMessageModel, conversation)) { await conversation.notify(mainMessageModel); } diff --git a/ts/util/sendEditedMessage.ts b/ts/util/sendEditedMessage.ts index 98e9baabb..07a99d1c2 100644 --- a/ts/util/sendEditedMessage.ts +++ b/ts/util/sendEditedMessage.ts @@ -198,6 +198,7 @@ export async function sendEditedMessage( const editAttributes = { conversationId, fromId, + fromDevice: window.storage.user.getDeviceId() ?? 1, message: tmpMessage, targetSentTimestamp, };