From 7542f040103ed80684cc865706cfbe141411b4bf Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 22 Jan 2024 14:07:19 +0300 Subject: [PATCH] Added specific phrases to chats list for voice messages with ttl. --- Telegram/Resources/langs/lang.strings | 2 ++ .../SourceFiles/data/data_media_types.cpp | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a3c13ac28..5a7771172 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2440,6 +2440,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_in_dlg_contact" = "Contact"; "lng_in_dlg_audio" = "Voice message"; "lng_in_dlg_video_message" = "Video message"; +"lng_in_dlg_voice_message_ttl" = "One-time Voice Message"; +"lng_in_dlg_video_message_ttl" = "One-time Video Message"; "lng_in_dlg_file" = "File"; "lng_in_dlg_sticker" = "Sticker"; "lng_in_dlg_sticker_emoji" = "{emoji} Sticker"; diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index fb6560e51..eee8ac7e1 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -983,13 +983,17 @@ ItemPreview MediaFile::toPreview(ToPreviewOptions options) const { const auto type = [&] { using namespace Ui::Text; if (_document->isVideoMessage()) { - return tr::lng_in_dlg_video_message(tr::now); + return (item->media() && item->media()->ttlSeconds()) + ? tr::lng_in_dlg_video_message_ttl(tr::now) + : tr::lng_in_dlg_video_message(tr::now); } else if (_document->isAnimation()) { return u"GIF"_q; } else if (_document->isVideoFile()) { return tr::lng_in_dlg_video(tr::now); } else if (_document->isVoiceMessage()) { - return tr::lng_in_dlg_audio(tr::now); + return (item->media() && item->media()->ttlSeconds()) + ? tr::lng_in_dlg_voice_message_ttl(tr::now) + : tr::lng_in_dlg_audio(tr::now); } else if (const auto name = FormatSongNameFor(_document).string(); !name.isEmpty()) { return name; @@ -1020,13 +1024,19 @@ TextWithEntities MediaFile::notificationText() const { } const auto type = [&] { if (_document->isVideoMessage()) { - return tr::lng_in_dlg_video_message(tr::now); + const auto media = parent()->media(); + return (media && media->ttlSeconds()) + ? tr::lng_in_dlg_video_message_ttl(tr::now) + : tr::lng_in_dlg_video_message(tr::now); } else if (_document->isAnimation()) { return u"GIF"_q; } else if (_document->isVideoFile()) { return tr::lng_in_dlg_video(tr::now); } else if (_document->isVoiceMessage()) { - return tr::lng_in_dlg_audio(tr::now); + const auto media = parent()->media(); + return (media && media->ttlSeconds()) + ? tr::lng_in_dlg_voice_message_ttl(tr::now) + : tr::lng_in_dlg_audio(tr::now); } else if (!_document->filename().isEmpty()) { return _document->filename(); } else if (_document->isAudioFile()) { @@ -1077,13 +1087,19 @@ TextForMimeData MediaFile::clipboardText() const { return tr::lng_in_dlg_sticker(tr::now); } else if (_document->isAnimation()) { if (_document->isVideoMessage()) { - return tr::lng_in_dlg_video_message(tr::now); + const auto media = parent()->media(); + return (media && media->ttlSeconds()) + ? tr::lng_in_dlg_video_message_ttl(tr::now) + : tr::lng_in_dlg_video_message(tr::now); } return u"GIF"_q; } else if (_document->isVideoFile()) { return tr::lng_in_dlg_video(tr::now); } else if (_document->isVoiceMessage()) { - return tr::lng_in_dlg_audio(tr::now) + addName; + const auto media = parent()->media(); + return ((media && media->ttlSeconds()) + ? tr::lng_in_dlg_voice_message_ttl + : tr::lng_in_dlg_audio)(tr::now) + addName;; } else if (_document->isSong()) { return tr::lng_in_dlg_audio_file(tr::now) + addName; }