2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 16:05:57 +00:00

Preload complex last message on demand.

This commit is contained in:
John Preston
2023-02-09 09:56:47 +04:00
parent 369862a3a7
commit f2ed77649e
11 changed files with 101 additions and 55 deletions

View File

@@ -471,17 +471,7 @@ void ForumTopic::applyTopicTopMessage(MsgId topMessageId) {
const auto itemId = FullMsgId(channel()->id, topMessageId);
if (const auto item = owner().message(itemId)) {
setLastServerMessage(item);
// If we set a single album part, request the full album.
if (item->groupId() != MessageGroupId()) {
if (owner().groups().isGroupOfOne(item)
&& !item->toPreview({
.hideSender = true,
.hideCaption = true }).images.empty()
&& _requestedGroups.emplace(item->fullId()).second) {
owner().histories().requestGroupAround(item);
}
}
resolveChatListMessageGroup();
} else {
setLastServerMessage(nullptr);
}
@@ -490,6 +480,23 @@ void ForumTopic::applyTopicTopMessage(MsgId topMessageId) {
}
}
void ForumTopic::resolveChatListMessageGroup() {
if (!(_flags & Flag::ResolveChatListMessage)) {
return;
}
// If we set a single album part, request the full album.
const auto item = _lastServerMessage.value_or(nullptr);
if (item && item->groupId() != MessageGroupId()) {
if (owner().groups().isGroupOfOne(item)
&& !item->toPreview({
.hideSender = true,
.hideCaption = true }).images.empty()
&& _requestedGroups.emplace(item->fullId()).second) {
owner().histories().requestGroupAround(item);
}
}
}
void ForumTopic::growLastKnownServerMessageId(MsgId id) {
_lastKnownServerMessageId = std::max(_lastKnownServerMessageId, id);
}
@@ -548,10 +555,11 @@ void ForumTopic::setChatListMessage(HistoryItem *item) {
_forum->listMessageChanged(was, item);
}
void ForumTopic::loadUserpic() {
void ForumTopic::chatListPreloadData() {
if (_icon) {
[[maybe_unused]] const auto preload = _icon->ready();
}
allowChatListMessageResolve();
}
void ForumTopic::paintUserpic(
@@ -840,6 +848,14 @@ Dialogs::UnreadState ForumTopic::unreadStateFor(
return result;
}
void ForumTopic::allowChatListMessageResolve() {
if (_flags & Flag::ResolveChatListMessage) {
return;
}
_flags |= Flag::ResolveChatListMessage;
resolveChatListMessageGroup();
}
HistoryItem *ForumTopic::chatListMessage() const {
return _lastMessage.value_or(nullptr);
}