From 49773dde72cd3f807e98086b26c189d2d0a41a59 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 1 Sep 2022 23:29:41 +0300 Subject: [PATCH] Attempted to fix rare non-elided text in bar of pinned bot messages. --- .../SourceFiles/history/history_widget.cpp | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index f0ae900117..851eb89030 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6417,31 +6417,39 @@ void HistoryWidget::checkPinnedBarState() { return controller()->isGifPausedAtLeastFor( Window::GifPauseReason::Any); }); + auto pinnedRefreshed = Info::Profile::SharedMediaCountValue( + _peer, + nullptr, + Storage::SharedMediaType::Pinned + ) | rpl::distinct_until_changed( + ) | rpl::map([=](int count) { + if (_pinnedClickedId) { + _pinnedClickedId = FullMsgId(); + _minPinnedId = std::nullopt; + updatePinnedViewer(); + } + return (count > 1); + }) | rpl::distinct_until_changed(); + auto markupRefreshed = HistoryView::PinnedBarItemWithReplyMarkup( + &session(), + _pinnedTracker->shownMessageId()); rpl::combine( - Info::Profile::SharedMediaCountValue( - _peer, - nullptr, - Storage::SharedMediaType::Pinned - ) | rpl::distinct_until_changed( - ) | rpl::map([=](int count) { - if (_pinnedClickedId) { - _pinnedClickedId = FullMsgId(); - _minPinnedId = std::nullopt; - updatePinnedViewer(); - } - return (count > 1); - }) | rpl::distinct_until_changed(), - HistoryView::PinnedBarItemWithReplyMarkup( - &session(), - _pinnedTracker->shownMessageId()) + rpl::duplicate(pinnedRefreshed), + rpl::duplicate(markupRefreshed) ) | rpl::start_with_next([=](bool many, HistoryItem *item) { refreshPinnedBarButton(many, item); }, _pinnedBar->lifetime()); - _pinnedBar->setContent(HistoryView::PinnedBarContent( - &session(), - _pinnedTracker->shownMessageId(), - [bar = _pinnedBar.get()] { bar->customEmojiRepaint(); })); + _pinnedBar->setContent(rpl::combine( + HistoryView::PinnedBarContent( + &session(), + _pinnedTracker->shownMessageId(), + [bar = _pinnedBar.get()] { bar->customEmojiRepaint(); }), + std::move(pinnedRefreshed), + std::move(markupRefreshed) + ) | rpl::map([](Ui::MessageBarContent &&content, bool, HistoryItem*) { + return std::move(content); + })); controller()->adaptive().oneColumnValue( ) | rpl::start_with_next([=](bool one) {