Don't re-create topic when clearing its messages.

This commit is contained in:
John Preston
2025-12-15 21:33:52 +04:00
parent b53ca51d37
commit 0b4a718afe
4 changed files with 16 additions and 2 deletions

View File

@@ -189,7 +189,9 @@ void History::checkChatListMessageRemoved(not_null<HistoryItem*> item) {
}
void History::itemVanished(not_null<HistoryItem*> item) {
item->notificationThread()->removeNotification(item);
if (const auto thread = item->maybeNotificationThread()) {
thread->removeNotification(item);
}
if (lastKeyboardId == item->id) {
clearLastKeyboard();
}

View File

@@ -1929,6 +1929,15 @@ not_null<Data::Thread*> HistoryItem::notificationThread() const {
return _history;
}
Data::Thread *HistoryItem::maybeNotificationThread() const {
if (const auto rootId = topicRootId()) {
if (const auto forum = _history->asForum()) {
return forum->topicFor(rootId);
}
}
return _history;
}
Data::ForumTopic *HistoryItem::topic() const {
if (const auto rootId = topicRootId()) {
if (const auto forum = _history->asForum()) {

View File

@@ -214,6 +214,7 @@ public:
[[nodiscard]] TextWithEntities factcheckText() const;
[[nodiscard]] not_null<Data::Thread*> notificationThread() const;
[[nodiscard]] Data::Thread *maybeNotificationThread() const;
[[nodiscard]] not_null<History*> history() const {
return _history;
}

View File

@@ -290,7 +290,9 @@ System::SkipState System::skipNotification(
const auto item = notification.item;
const auto type = notification.type;
const auto messageType = (type == Data::ItemNotificationType::Message);
if (!item->notificationThread()->currentNotification()
const auto thread = item->maybeNotificationThread();
if (!thread
|| !thread->currentNotification()
|| (messageType && item->skipNotification())
|| (type == Data::ItemNotificationType::Reaction
&& skipReactionNotification(item))) {