From ff3e3464337ab7af0caf75694268feadc56d6bf2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 26 Dec 2025 18:34:42 +0400 Subject: [PATCH] Use correct text update for summarize. --- .../history/view/history_view_element.cpp | 22 ++++++++++--------- .../history/view/history_view_element.h | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index b97650a7ed..03a369e038 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -1670,18 +1670,20 @@ void Element::validateText() { return; } } - { - const auto &summary - = item->history()->session().api().transcribes().summary(item); - if (!summary.result.empty() && summary.shown) { + const auto summaryShownWas = (_flags & Flag::SummaryShown) != 0; + const auto transcribes = &history()->session().api().transcribes(); + const auto &summary = transcribes->summary(item); + const auto summaryShownNow = !summary.result.empty() && summary.shown; + const auto summaryShownChanged = (summaryShownWas != summaryShownNow); + if (summaryShownNow) { + _flags |= Flag::SummaryShown; + if (summaryShownChanged) { _textItem = item; setTextWithLinks(summary.result); - return; - } - if (!summary.result.empty() && !summary.shown) { - _textItem = item; - setTextWithLinks(item->originalText()); } + return; + } else { + _flags &= ~Flag::SummaryShown; } // Albums may show text of a different item than the parent one. @@ -1693,7 +1695,7 @@ void Element::validateText() { return; } const auto &text = _textItem->_text; - if (_text.isEmpty() == text.empty()) { + if (!summaryShownChanged && _text.isEmpty() == text.empty()) { } else if (_flags & Flag::ServiceMessage) { const auto contextDependentText = contextDependentServiceText(); const auto &markedText = contextDependentText.text.empty() diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 2d9398ab46..2e5aaf6129 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -397,6 +397,7 @@ public: TopicRootReply = 0x0400, MediaOverriden = 0x0800, HeavyCustomEmoji = 0x1000, + SummaryShown = 0x2000, }; using Flags = base::flags; friend inline constexpr auto is_flag_type(Flag) { return true; }