From 02aaa71e78c13a92252b32b25e00db5ede3baa56 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 8 Jul 2025 12:32:42 +0400 Subject: [PATCH] Fix updating sublist chats in Saved Messages. Fixes #29448. --- .../SourceFiles/data/data_saved_sublist.cpp | 32 ++++++++++++++++++- Telegram/SourceFiles/history/history_item.cpp | 5 ++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/data/data_saved_sublist.cpp b/Telegram/SourceFiles/data/data_saved_sublist.cpp index 64ef0886df..7eab828dd4 100644 --- a/Telegram/SourceFiles/data/data_saved_sublist.cpp +++ b/Telegram/SourceFiles/data/data_saved_sublist.cpp @@ -217,7 +217,28 @@ void SavedSublist::applyItemRemoved(MsgId id) { if (const auto chatListItem = _chatListMessage.value_or(nullptr)) { if (chatListItem->id == id) { _chatListMessage = std::nullopt; - requestChatListMessage(); + crl::on_main(this, [=] { + // We didn't yet update _list here. + if (_chatListMessage.has_value()) { + return; + } else if (_skippedAfter == 0) { + if (!_list.empty()) { + applyMaybeLast(owner().message( + owningHistory()->peer, + _list.front())); + return; + } else if (_skippedBefore == 0) { + setLastServerMessage(nullptr); + updateChatListExistence(); + return; + } + } + if (_parent->parentChat()) { + requestChatListMessage(); + } else { + loadAround(0); + } + }); } } } @@ -1110,6 +1131,10 @@ void SavedSublist::loadAround(MsgId id) { _list.clear(); if (processMessagesIsEmpty(result)) { _fullCount = _skippedBefore = _skippedAfter = 0; + if (!_parent->parentChat() && !_chatListMessage) { + setLastServerMessage(nullptr); + updateChatListExistence(); + } } else if (id) { Assert(!_list.empty()); if (_list.front() <= id) { @@ -1117,6 +1142,11 @@ void SavedSublist::loadAround(MsgId id) { } else if (_list.back() >= id) { _skippedBefore = 0; } + } else if (!_parent->parentChat() && !_chatListMessage) { + Assert(!_list.empty()); + applyMaybeLast(owner().message( + owningHistory()->peer, + _list.front())); } checkReadTillEnd(); }).fail([=](const MTP::Error &error) { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 2f8c24b60f..c803b59abc 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1784,7 +1784,10 @@ bool HistoryItem::isSponsored() const { } bool HistoryItem::canLookupMessageAuthor() const { - return isRegular() && _history->amMonoforumAdmin() && _from->isChannel(); + return isRegular() + && !isService() + && _history->amMonoforumAdmin() + && _from->isChannel(); } bool HistoryItem::skipNotification() const {