From d6e827e9827dcaba54477fe866b3282025e27ed0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 29 May 2024 10:48:41 +0400 Subject: [PATCH] Fix loading of chat preview messages. --- Telegram/SourceFiles/data/data_history_messages.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_history_messages.cpp b/Telegram/SourceFiles/data/data_history_messages.cpp index 86b46503d..66e888e28 100644 --- a/Telegram/SourceFiles/data/data_history_messages.cpp +++ b/Telegram/SourceFiles/data/data_history_messages.cpp @@ -89,6 +89,13 @@ rpl::producer HistoryViewer( using RequestAroundInfo = SparseIdsSliceBuilder::AroundData; builder->insufficientAround( ) | rpl::start_with_next([=](const RequestAroundInfo &info) { + if (!info.aroundId) { + // Ignore messages-count-only requests, because we perform + // them with non-zero limit of messages and end up adding + // a broken slice with several last messages from the chat + // with a non-skip range starting at zero. + return; + } history->session().api().requestHistory( history, info.aroundId, @@ -155,7 +162,7 @@ rpl::producer HistoryMergedViewer( }; const auto peerId = history->peer->id; const auto topicRootId = MsgId(); - const auto migratedPeerId = migrateFrom ? migrateFrom->id : peerId; + const auto migratedPeerId = migrateFrom ? migrateFrom->id : PeerId(0); using Key = SparseIdsMergedSlice::Key; return SparseIdsMergedSlice::CreateViewer( Key(peerId, topicRootId, migratedPeerId, universalAroundId),