mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix leaving forum glitch.
This commit is contained in:
parent
bfbdf1b935
commit
eec59611ef
1 changed files with 17 additions and 10 deletions
|
@ -1271,24 +1271,31 @@ History *Session::historyLoaded(const PeerData *peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::deleteConversationLocally(not_null<PeerData*> peer) {
|
void Session::deleteConversationLocally(not_null<PeerData*> peer) {
|
||||||
const auto history = historyLoaded(peer);
|
const auto markLeft = [&] {
|
||||||
if (history) {
|
if (const auto channel = peer->asMegagroup()) {
|
||||||
|
channel->addFlags(ChannelDataFlag::Left);
|
||||||
|
if (const auto from = channel->getMigrateFromChat()) {
|
||||||
|
if (const auto migrated = historyLoaded(from)) {
|
||||||
|
migrated->updateChatListExistence();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (const auto history = historyLoaded(peer)) {
|
||||||
if (history->folderKnown()) {
|
if (history->folderKnown()) {
|
||||||
setChatPinned(history, FilterId(), false);
|
setChatPinned(history, FilterId(), false);
|
||||||
}
|
}
|
||||||
removeChatListEntry(history);
|
removeChatListEntry(history);
|
||||||
history->clearFolder();
|
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->clear(peer->isChannel()
|
||||||
? History::ClearType::Unload
|
? History::ClearType::Unload
|
||||||
: History::ClearType::DeleteChat);
|
: History::ClearType::DeleteChat);
|
||||||
}
|
} else {
|
||||||
if (const auto channel = peer->asMegagroup()) {
|
markLeft();
|
||||||
channel->addFlags(ChannelDataFlag::Left);
|
|
||||||
if (const auto from = channel->getMigrateFromChat()) {
|
|
||||||
if (const auto migrated = historyLoaded(from)) {
|
|
||||||
migrated->updateChatListExistence();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue