Message: Fix copying selected messages duplicates caption text (#2942)

This commit is contained in:
Alexander Zinchuk 2023-04-15 13:50:51 +02:00
parent 3d2c353e9b
commit 2f63a0fcf0

View File

@ -119,17 +119,21 @@ export function getMessageSummaryDescription(
game, game,
} = message.content; } = message.content;
let hasUsedTruncatedText = false;
let summary: string | TeactNode | undefined; let summary: string | TeactNode | undefined;
if (message.groupedId) { if (message.groupedId) {
hasUsedTruncatedText = true;
summary = truncatedText || lang('lng_in_dlg_album'); summary = truncatedText || lang('lng_in_dlg_album');
} }
if (photo) { if (photo) {
hasUsedTruncatedText = true;
summary = truncatedText || lang('AttachPhoto'); summary = truncatedText || lang('AttachPhoto');
} }
if (video) { if (video) {
hasUsedTruncatedText = true;
summary = truncatedText || lang(video.isGif ? 'AttachGif' : 'AttachVideo'); summary = truncatedText || lang(video.isGif ? 'AttachGif' : 'AttachVideo');
} }
@ -142,10 +146,12 @@ export function getMessageSummaryDescription(
} }
if (voice) { if (voice) {
hasUsedTruncatedText = true;
summary = truncatedText || lang('AttachAudio'); summary = truncatedText || lang('AttachAudio');
} }
if (document) { if (document) {
hasUsedTruncatedText = !isExtended;
summary = isExtended ? document.fileName : (truncatedText || document.fileName); summary = isExtended ? document.fileName : (truncatedText || document.fileName);
} }
@ -162,7 +168,7 @@ export function getMessageSummaryDescription(
} }
if (text) { if (text) {
if (isExtended && summary) { if (isExtended && summary && !hasUsedTruncatedText) {
summary += `\n${truncatedText}`; summary += `\n${truncatedText}`;
} else { } else {
summary = truncatedText; summary = truncatedText;