mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Always keep General topic, don't delete all.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user