Always keep General topic, don't delete all.

This commit is contained in:
John Preston
2026-01-02 14:46:27 +04:00
parent 02667395ee
commit c8c327566b
+17 -5
View File
@@ -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<ForumTopic>(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);
});
}
}