diff --git a/Telegram/SourceFiles/history/history_item_helpers.cpp b/Telegram/SourceFiles/history/history_item_helpers.cpp index a249195c9d..4a29e4e93d 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.cpp +++ b/Telegram/SourceFiles/history/history_item_helpers.cpp @@ -808,3 +808,7 @@ void ClearMediaAsExpired(not_null item) { } } } + +[[nodiscard]] bool IsVoiceOncePlayable(not_null item) { + return !item->out() && item->media()->ttlSeconds(); +} diff --git a/Telegram/SourceFiles/history/history_item_helpers.h b/Telegram/SourceFiles/history/history_item_helpers.h index c438eccbe1..f96d9c0922 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.h +++ b/Telegram/SourceFiles/history/history_item_helpers.h @@ -158,3 +158,4 @@ ClickHandlerPtr JumpToStoryClickHandler( void ShowTrialTranscribesToast(int left, TimeId until); void ClearMediaAsExpired(not_null item); +[[nodiscard]] bool IsVoiceOncePlayable(not_null item); diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index f1d273d635..867c365ddd 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/audio/media_audio.h" #include "media/player/media_player_instance.h" #include "history/history_item_components.h" -#include "history/history_item_helpers.h" // PreparedServiceText. +#include "history/history_item_helpers.h" // ClearMediaAsExpired. #include "history/history.h" #include "core/click_handler_types.h" // kDocumentFilenameTooltipProperty. #include "history/view/history_view_element.h" @@ -96,10 +96,6 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100); }; } -[[nodiscard]] bool OncePlayable(not_null item) { - return !item->out() && item->media()->ttlSeconds(); -} - [[nodiscard]] QString CleanTagSymbols(const QString &value) { auto result = QString(); const auto begin = value.begin(), end = value.end(); @@ -264,7 +260,7 @@ Document::Document( } if ((_data->isVoiceMessage() || isRound) - && OncePlayable(_parent->data())) { + && IsVoiceOncePlayable(_parent->data())) { _parent->data()->removeFromSharedMediaIndex(); setDocumentLinks(_data, realParent, [=] { _openl = nullptr; @@ -288,14 +284,7 @@ Document::Document( ) | rpl::start_with_next([=]() mutable { const auto item = _parent->data(); // Destroys this. - item->applyEditionToHistoryCleared(); - item->updateServiceText(PreparedServiceText{ - (isRound - ? tr::lng_ttl_round_expired - : tr::lng_ttl_voice_expired)( - tr::now, - Ui::Text::WithEntities) - }); + ClearMediaAsExpired(_parent->data()); if (lifetime) { _drawTtl = nullptr; base::take(lifetime)->destroy(); @@ -371,7 +360,7 @@ void Document::createComponents(bool caption) { _realParent->fullId()); } if (const auto voice = Get()) { - voice->seekl = !OncePlayable(_parent->data()) + voice->seekl = !IsVoiceOncePlayable(_parent->data()) ? std::make_shared(_data, [](FullMsgId) {}) : nullptr; if (_transcribedRound) { @@ -404,7 +393,9 @@ QSize Document::countOptimalSize() { const auto voice = Get(); if (voice) { const auto session = &_realParent->history()->session(); - if (!session->premium() && !session->api().transcribes().trialsSupport()) { + if (IsVoiceOncePlayable(_parent->data()) + || (!session->premium() + && !session->api().transcribes().trialsSupport())) { voice->transcribe = nullptr; voice->transcribeText = {}; } else { diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 42247802aa..e06ecb9090 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "ui/painter.h" #include "history/history_item_components.h" +#include "history/history_item_helpers.h" #include "history/history_item.h" #include "history/history.h" #include "history/view/history_view_element.h" @@ -1974,6 +1975,7 @@ bool Gif::needCornerStatusDisplay() const { void Gif::ensureTranscribeButton() const { if (_data->isVideoMessage() + && !IsVoiceOncePlayable(_parent->data()) && (_data->session().premium() || _data->session().api().transcribes().trialsSupport())) { if (!_transcribe) {