From 2f63a0fcf022138dfb98c0cf4dc293e3fbe1e40c Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sat, 15 Apr 2023 13:50:51 +0200 Subject: [PATCH] Message: Fix copying selected messages duplicates caption text (#2942) --- src/global/helpers/messageSummary.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/global/helpers/messageSummary.ts b/src/global/helpers/messageSummary.ts index 0663e04fb..343a47872 100644 --- a/src/global/helpers/messageSummary.ts +++ b/src/global/helpers/messageSummary.ts @@ -119,17 +119,21 @@ export function getMessageSummaryDescription( game, } = message.content; + let hasUsedTruncatedText = false; let summary: string | TeactNode | undefined; if (message.groupedId) { + hasUsedTruncatedText = true; summary = truncatedText || lang('lng_in_dlg_album'); } if (photo) { + hasUsedTruncatedText = true; summary = truncatedText || lang('AttachPhoto'); } if (video) { + hasUsedTruncatedText = true; summary = truncatedText || lang(video.isGif ? 'AttachGif' : 'AttachVideo'); } @@ -142,10 +146,12 @@ export function getMessageSummaryDescription( } if (voice) { + hasUsedTruncatedText = true; summary = truncatedText || lang('AttachAudio'); } if (document) { + hasUsedTruncatedText = !isExtended; summary = isExtended ? document.fileName : (truncatedText || document.fileName); } @@ -162,7 +168,7 @@ export function getMessageSummaryDescription( } if (text) { - if (isExtended && summary) { + if (isExtended && summary && !hasUsedTruncatedText) { summary += `\n${truncatedText}`; } else { summary = truncatedText;