From fcf9ca3982dbc0fd2b35149c5a9daf8af62c6f62 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 28 Oct 2022 09:54:39 +0400 Subject: [PATCH] Fix local pinned hiding in topics. --- Telegram/SourceFiles/history/history_widget.cpp | 1 + .../history/view/history_view_replies_section.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 1a0979805..b402c9436 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6235,6 +6235,7 @@ void HistoryWidget::checkPinnedBarState() { }; auto destroyer = [this, object = std::move(qobject)]() mutable { object = nullptr; + _pinnedBarHeight = 0; updateHistoryGeometry(); updateControlsGeometry(); }; diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 083a8e7f5..8d18988ac 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1505,6 +1505,18 @@ void RepliesWidget::setupPinnedTracker() { return result.fullCount().has_value(); }) | rpl::start_with_next([=](const SparseIdsSlice &result) { _topic->setHasPinnedMessages(*result.fullCount() != 0); + if (result.skippedAfter() == 0) { + auto &settings = _history->session().settings(); + const auto peerId = _history->peer->id; + const auto hiddenId = settings.hiddenPinnedMessageId( + peerId, + _rootId); + const auto last = result.size() ? result[result.size() - 1] : 0; + if (hiddenId && hiddenId != last) { + settings.setHiddenPinnedMessageId(peerId, _rootId, 0); + _history->session().saveSettingsDelayed(); + } + } checkPinnedBarState(); }, _topicLifetime); } @@ -1521,7 +1533,7 @@ void RepliesWidget::checkPinnedBarState() { _rootId); const auto currentPinnedId = Data::ResolveTopPinnedId(peer, _rootId); const auto universalPinnedId = !currentPinnedId - ? int32(0) + ? MsgId(0) : currentPinnedId.msg; if (universalPinnedId == hiddenId) { if (_pinnedBar) { @@ -1531,6 +1543,7 @@ void RepliesWidget::checkPinnedBarState() { }; auto destroyer = [this, object = std::move(qobject)]() mutable { object = nullptr; + _pinnedBarHeight = 0; updateControlsGeometry(); }; base::call_delayed(