2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 15:05:56 +00:00

Fix opening Replies section on unread bar.

This commit is contained in:
John Preston
2020-10-02 19:26:04 +03:00
parent 8d70a62ee8
commit 4b6d74dd9b
7 changed files with 45 additions and 10 deletions

View File

@@ -227,6 +227,7 @@ void RepliesList::injectRootDivider(
bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
if (_list.empty() && _skippedBefore == 0 && _skippedAfter == 0) {
viewer->slice.ids.clear();
viewer->slice.nearestToAround = FullMsgId();
viewer->slice.fullCount
= viewer->slice.skippedBefore
= viewer->slice.skippedAfter
@@ -268,10 +269,20 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
const auto channelId = _history->channelId();
slice->ids.clear();
auto nearestToAround = std::optional<MsgId>();
slice->ids.reserve(useAfter + useBefore);
for (auto j = i - useAfter, e = i + useBefore; j != e; ++j) {
if (!nearestToAround && *j < around) {
nearestToAround = (j == i - useAfter)
? *j
: *(j - 1);
}
slice->ids.emplace_back(channelId, *j);
}
slice->nearestToAround = FullMsgId(
channelId,
nearestToAround.value_or(
slice->ids.empty() ? 0 : slice->ids.back().msg));
slice->fullCount = _fullCount.current();
injectRootMessageAndReverse(slice);