Fix migrated history in chat preview.

This commit is contained in:
John Preston 2024-05-03 18:28:52 +04:00
parent 0f524ac67d
commit aee62c7591
2 changed files with 5 additions and 3 deletions

View file

@ -151,7 +151,7 @@ rpl::producer<SparseIdsMergedSlice> 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();

View file

@ -3107,8 +3107,9 @@ Data::HistoryMessages &History::messages() {
if (!_messages) {
_messages = std::make_unique<Data::HistoryMessages>();
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<MsgId>();
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 }, {});
}
}