From 14b603991f84c8ff99a2dffad548e2974acf96c6 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 19 Apr 2022 15:12:13 +0200 Subject: [PATCH] Service Notifications: Fix loading media --- src/global/actions/ui/messages.ts | 1 + src/global/helpers/messages.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/global/actions/ui/messages.ts b/src/global/actions/ui/messages.ts index 1eb5f6139..f26b19740 100644 --- a/src/global/actions/ui/messages.ts +++ b/src/global/actions/ui/messages.ts @@ -632,6 +632,7 @@ addActionHandler('createServiceNotification', (global, actions, payload) => { // The fractional ID is made of the largest integer ID and an incremented fractional part const id = Math.floor(maxId) + fractionalPart; + message.previousLocalId = message.id; message.id = id; const serviceNotification = { diff --git a/src/global/helpers/messages.ts b/src/global/helpers/messages.ts index cda288a16..c983fe89b 100644 --- a/src/global/helpers/messages.ts +++ b/src/global/helpers/messages.ts @@ -23,9 +23,9 @@ export function getMessageHtmlId(messageId: number) { } export function getMessageKey(message: ApiMessage): MessageKey { - const { chatId, id } = message; + const { chatId, id, previousLocalId } = message; - return buildMessageKey(chatId, id); + return buildMessageKey(chatId, isServiceNotificationMessage(message) ? previousLocalId || id : id); } export function buildMessageKey(chatId: string, msgId: number): MessageKey {