From c8c327566b44b96faffa6eb407eefedfa9052cf3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 2 Jan 2026 14:46:27 +0400 Subject: [PATCH] Always keep General topic, don't delete all. --- Telegram/SourceFiles/data/data_forum.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/data/data_forum.cpp b/Telegram/SourceFiles/data/data_forum.cpp index a82afd9b4b..2ce2861839 100644 --- a/Telegram/SourceFiles/data/data_forum.cpp +++ b/Telegram/SourceFiles/data/data_forum.cpp @@ -366,10 +366,7 @@ void Forum::applyReceivedTopics( const auto rootId = topic.match([&](const auto &data) { return data.vid().v; }); - _staleRootIds.remove(rootId); - topic.match([&](const MTPDforumTopicDeleted &data) { - applyTopicDeleted(rootId); - }, [&](const MTPDforumTopic &data) { + const auto apply = [&](const MTPDforumTopic *fields = nullptr) { _topicsDeleted.remove(rootId); const auto i = _topics.find(rootId); const auto creating = (i == end(_topics)); @@ -379,7 +376,9 @@ void Forum::applyReceivedTopics( std::make_unique(this, rootId) ).first->second.get() : i->second.get(); - raw->applyTopic(data); + if (fields) { + raw->applyTopic(*fields); + } if (creating) { if (const auto last = _history->chatListMessage() ; last && last->topicRootId() == rootId) { @@ -390,6 +389,19 @@ void Forum::applyReceivedTopics( if (callback) { callback(raw); } + }; + + _staleRootIds.remove(rootId); + topic.match([&](const MTPDforumTopicDeleted &data) { + if (rootId != ForumTopic::kGeneralId) { + applyTopicDeleted(rootId); + } else { + // We shouldn't delete general topic in any case. + // Here this happens in bot forums, for example. + apply(); + } + }, [&](const MTPDforumTopic &data) { + apply(&data); }); } }