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 }, {}); } }