From 0b4a718afef70b5b53d31f78d231db7ffa0589fc Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 15 Dec 2025 21:33:52 +0400 Subject: [PATCH] Don't re-create topic when clearing its messages. --- Telegram/SourceFiles/history/history.cpp | 4 +++- Telegram/SourceFiles/history/history_item.cpp | 9 +++++++++ Telegram/SourceFiles/history/history_item.h | 1 + Telegram/SourceFiles/window/notifications_manager.cpp | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 08c7706d6a..d22743f532 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -189,7 +189,9 @@ void History::checkChatListMessageRemoved(not_null item) { } void History::itemVanished(not_null item) { - item->notificationThread()->removeNotification(item); + if (const auto thread = item->maybeNotificationThread()) { + thread->removeNotification(item); + } if (lastKeyboardId == item->id) { clearLastKeyboard(); } diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index daa9e36570..849b150da1 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1929,6 +1929,15 @@ not_null 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()) { diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 5307289658..b350a34506 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -214,6 +214,7 @@ public: [[nodiscard]] TextWithEntities factcheckText() const; [[nodiscard]] not_null notificationThread() const; + [[nodiscard]] Data::Thread *maybeNotificationThread() const; [[nodiscard]] not_null history() const { return _history; } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 4dcf85beae..3ef706f761 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -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))) {