Fix leaving forum glitch.

This commit is contained in:
John Preston 2024-08-17 17:09:28 +02:00
parent bfbdf1b935
commit eec59611ef

View file

@ -1271,17 +1271,7 @@ History *Session::historyLoaded(const PeerData *peer) {
}
void Session::deleteConversationLocally(not_null<PeerData*> peer) {
const auto history = historyLoaded(peer);
if (history) {
if (history->folderKnown()) {
setChatPinned(history, FilterId(), false);
}
removeChatListEntry(history);
history->clearFolder();
history->clear(peer->isChannel()
? History::ClearType::Unload
: History::ClearType::DeleteChat);
}
const auto markLeft = [&] {
if (const auto channel = peer->asMegagroup()) {
channel->addFlags(ChannelDataFlag::Left);
if (const auto from = channel->getMigrateFromChat()) {
@ -1290,6 +1280,23 @@ void Session::deleteConversationLocally(not_null<PeerData*> peer) {
}
}
}
};
if (const auto history = historyLoaded(peer)) {
if (history->folderKnown()) {
setChatPinned(history, FilterId(), false);
}
removeChatListEntry(history);
history->clearFolder();
// We want to mark the channel as left before unloading the history,
// otherwise some parts of updating may return us to the chats list.
markLeft();
history->clear(peer->isChannel()
? History::ClearType::Unload
: History::ClearType::DeleteChat);
} else {
markLeft();
}
}
bool Session::chatsListLoaded(Data::Folder *folder) {