From a02c01cce7da98879bbb0e856fb908369161cca8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 8 Nov 2022 18:25:43 +0300 Subject: [PATCH] Added phrases for various types of albums in chats list. --- Telegram/Resources/langs/lang.strings | 10 ++++++ .../SourceFiles/data/data_media_types.cpp | 31 ++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a5a147ebf..4cacf04bc 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1936,6 +1936,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_in_dlg_sticker" = "Sticker"; "lng_in_dlg_sticker_emoji" = "{emoji} Sticker"; "lng_in_dlg_poll" = "Poll"; +"lng_in_dlg_media_count#one" = "{count} media"; +"lng_in_dlg_media_count#other" = "{count} media"; +"lng_in_dlg_photo_count#one" = "{count} photo"; +"lng_in_dlg_photo_count#other" = "{count} photos"; +"lng_in_dlg_video_count#one" = "{count} video"; +"lng_in_dlg_video_count#other" = "{count} videos"; +"lng_in_dlg_file_count#one" = "{count} file"; +"lng_in_dlg_file_count#other" = "{count} files"; +"lng_in_dlg_audio_count#one" = "{count} audio"; +"lng_in_dlg_audio_count#other" = "{count} audio"; "lng_ban_user" = "Ban User"; "lng_delete_all_from_user" = "Delete all from {user}"; diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 25fed8947..d72ef26f5 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -462,12 +462,23 @@ std::unique_ptr Media::createView( ItemPreview Media::toGroupPreview( const HistoryItemsList &items, ToPreviewOptions options) const { - const auto genericText = Ui::Text::PlainLink( - tr::lng_in_dlg_album(tr::now)); auto result = ItemPreview(); auto loadingContext = std::vector(); + auto photoCount = 0; + auto videoCount = 0; + auto audioCount = 0; + auto fileCount = 0; for (const auto &item : items) { if (const auto media = item->media()) { + if (media->photo()) { + photoCount++; + } else if (const auto document = media->document()) { + (document->isVideoFile() + ? videoCount + : document->isAudioFile() + ? audioCount + : fileCount)++; + } auto copy = options; copy.ignoreGroup = true; const auto already = int(result.images.size()); @@ -490,13 +501,25 @@ ItemPreview Media::toGroupPreview( if (result.text.text.isEmpty()) { result.text = original; } else { - result.text = genericText; + result.text = {}; } } } } if (result.text.text.isEmpty()) { - result.text = genericText; + const auto mediaCount = photoCount + videoCount; + auto genericText = (photoCount && videoCount) + ? tr::lng_in_dlg_media_count(tr::now, lt_count, mediaCount) + : photoCount + ? tr::lng_in_dlg_photo_count(tr::now, lt_count, photoCount) + : videoCount + ? tr::lng_in_dlg_video_count(tr::now, lt_count, videoCount) + : audioCount + ? tr::lng_in_dlg_audio_count(tr::now, lt_count, audioCount) + : fileCount + ? tr::lng_in_dlg_file_count(tr::now, lt_count, fileCount) + : tr::lng_in_dlg_album(tr::now); + result.text = Ui::Text::PlainLink(genericText); } if (!loadingContext.empty()) { result.loadingContext = std::move(loadingContext);