From aee62c7591e530c69b386b41b738a63bddbdc5cd Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 3 May 2024 18:28:52 +0400 Subject: [PATCH] Fix migrated history in chat preview. --- Telegram/SourceFiles/data/data_history_messages.cpp | 2 +- Telegram/SourceFiles/history/history.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_history_messages.cpp b/Telegram/SourceFiles/data/data_history_messages.cpp index 7c29daf9e..86b46503d 100644 --- a/Telegram/SourceFiles/data/data_history_messages.cpp +++ b/Telegram/SourceFiles/data/data_history_messages.cpp @@ -151,7 +151,7 @@ rpl::producer HistoryMergedViewer( const auto chosen = (history->peer->id == peerId) ? history : history->owner().history(peerId); - return HistoryViewer(history, simpleKey, limitBefore, limitAfter); + return HistoryViewer(chosen, simpleKey, limitBefore, limitAfter); }; const auto peerId = history->peer->id; const auto topicRootId = MsgId(); diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 3643ed726..02a3324b9 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -3107,8 +3107,9 @@ Data::HistoryMessages &History::messages() { if (!_messages) { _messages = std::make_unique(); + const auto max = maxMsgId(); const auto from = loadedAtTop() ? 0 : minMsgId(); - const auto till = loadedAtBottom() ? ServerMaxMsgId : maxMsgId(); + const auto till = loadedAtBottom() ? ServerMaxMsgId : max; auto list = std::vector(); list.reserve(std::min( int(_items.size()), @@ -3122,13 +3123,14 @@ Data::HistoryMessages &History::messages() { if (!list.empty() && list.back() >= id) { sort = true; } + list.push_back(id); } } } if (sort) { ranges::sort(list); } - if (till) { + if (max || (loadedAtTop() && loadedAtBottom())) { _messages->addSlice(std::move(list), { from, till }, {}); } }