Make less channel full requests.

This commit is contained in:
John Preston 2025-06-27 18:12:25 +04:00
parent ff4b9a3cfe
commit bd5b9f5347
2 changed files with 35 additions and 14 deletions

View file

@ -1060,15 +1060,9 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
}
channel->setPhoto(data.vphoto());
if (const auto monoforum = data.vlinked_monoforum_id()) {
if (const auto linked = channelLoaded(monoforum->v)) {
channel->setMonoforumLink(linked);
} else {
channel->updateFull();
}
} else {
channel->setMonoforumLink(nullptr);
}
applyMonoforumLinkedId(
channel,
data.vlinked_monoforum_id().value_or_empty());
if (wasInChannel != channel->amIn()) {
flags |= UpdateFlag::ChannelAmIn;
@ -1152,12 +1146,31 @@ UserData *Session::processUsers(const MTPVector<MTPUser> &data) {
PeerData *Session::processChats(const MTPVector<MTPChat> &data) {
auto result = (PeerData*)nullptr;
_postponedMonoforumLinkedIds.emplace();
for (const auto &chat : data.v) {
result = processChat(chat);
}
const auto ids = base::take(_postponedMonoforumLinkedIds);
for (const auto &[channel, linkedId] : *ids) {
applyMonoforumLinkedId(channel, linkedId);
}
return result;
}
void Session::applyMonoforumLinkedId(
not_null<ChannelData*> channel,
ChannelId linkedId) {
if (!linkedId) {
channel->setMonoforumLink(nullptr);
} else if (_postponedMonoforumLinkedIds) {
_postponedMonoforumLinkedIds->emplace(channel, linkedId);
} else if (const auto linked = channelLoaded(linkedId)) {
channel->setMonoforumLink(linked);
} else {
channel->updateFull();
}
}
void Session::applyMaximumChatVersions(const MTPVector<MTPChat> &data) {
for (const auto &chat : data.v) {
chat.match([&](const MTPDchat &data) {
@ -4809,11 +4822,11 @@ void Session::refreshChatListEntry(Dialogs::Key key) {
} else if (const auto monoforum = history->peer->monoforum()) {
monoforum->preloadSublists();
}
if (const auto broadcast = history->peer->monoforumBroadcast()) {
if (!broadcast->isFullLoaded()) {
broadcast->updateFull();
}
}
//if (const auto broadcast = history->peer->monoforumBroadcast()) {
// if (!broadcast->isFullLoaded()) {
// broadcast->updateFull();
// }
//}
}
}

View file

@ -992,6 +992,10 @@ private:
void setWallpapers(const QVector<MTPWallPaper> &data, uint64 hash);
void highlightProcessDone(uint64 processId);
void applyMonoforumLinkedId(
not_null<ChannelData*> channel,
ChannelId linkedId);
void checkPollsClosings();
const not_null<Main::Session*> _session;
@ -1157,6 +1161,10 @@ private:
std::unordered_map<PeerId, std::unique_ptr<PeerData>> _peers;
std::optional<base::flat_map<
not_null<ChannelData*>,
ChannelId>> _postponedMonoforumLinkedIds;
MessageIdsList _mimeForwardIds;
std::weak_ptr<CreditsSubsRebuilder> _creditsSubsRebuilder;