mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Inject discussed message when no comments.
This commit is contained in:
parent
883c3ecf65
commit
cf48152853
2 changed files with 18 additions and 6 deletions
|
@ -156,6 +156,18 @@ rpl::producer<int> RepliesList::fullCount() const {
|
||||||
return _fullCount.value() | rpl::filter_optional();
|
return _fullCount.value() | rpl::filter_optional();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RepliesList::injectRootMessage(not_null<MessagesSlice*> slice) {
|
||||||
|
if (slice->skippedBefore != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (const auto root = lookupRoot()) {
|
||||||
|
slice->ids.push_back(root->fullId());
|
||||||
|
if (slice->fullCount) {
|
||||||
|
++*slice->fullCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
|
bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
|
||||||
if (_list.empty() && _skippedBefore == 0 && _skippedAfter == 0) {
|
if (_list.empty() && _skippedBefore == 0 && _skippedAfter == 0) {
|
||||||
viewer->slice.ids.clear();
|
viewer->slice.ids.clear();
|
||||||
|
@ -163,6 +175,7 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
|
||||||
= viewer->slice.skippedBefore
|
= viewer->slice.skippedBefore
|
||||||
= viewer->slice.skippedAfter
|
= viewer->slice.skippedAfter
|
||||||
= 0;
|
= 0;
|
||||||
|
injectRootMessage(&viewer->slice);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const auto around = [&] {
|
const auto around = [&] {
|
||||||
|
@ -205,14 +218,12 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
|
||||||
for (auto j = i - useAfter, e = i + useBefore; j != e; ++j) {
|
for (auto j = i - useAfter, e = i + useBefore; j != e; ++j) {
|
||||||
slice->ids.emplace_back(channelId, *j);
|
slice->ids.emplace_back(channelId, *j);
|
||||||
}
|
}
|
||||||
if (slice->skippedBefore == 0) {
|
slice->fullCount = _fullCount.current();
|
||||||
if (const auto root = lookupRoot()) {
|
|
||||||
slice->ids.push_back(root->fullId());
|
injectRootMessage(slice);
|
||||||
}
|
|
||||||
}
|
|
||||||
ranges::reverse(slice->ids);
|
ranges::reverse(slice->ids);
|
||||||
|
|
||||||
slice->fullCount = _fullCount.current();
|
|
||||||
if (_skippedBefore != 0 && useBefore < viewer->limitBefore + 1) {
|
if (_skippedBefore != 0 && useBefore < viewer->limitBefore + 1) {
|
||||||
loadBefore();
|
loadBefore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ private:
|
||||||
[[nodiscard]] bool applyUpdate(
|
[[nodiscard]] bool applyUpdate(
|
||||||
not_null<Viewer*> viewer,
|
not_null<Viewer*> viewer,
|
||||||
const MessageUpdate &update);
|
const MessageUpdate &update);
|
||||||
|
void injectRootMessage(not_null<MessagesSlice*> slice);
|
||||||
bool processMessagesIsEmpty(const MTPmessages_Messages &result);
|
bool processMessagesIsEmpty(const MTPmessages_Messages &result);
|
||||||
void loadAround(MsgId id);
|
void loadAround(MsgId id);
|
||||||
void loadBefore();
|
void loadBefore();
|
||||||
|
|
Loading…
Add table
Reference in a new issue