| 1533 | } |
| 1534 | |
| 1535 | void Session::deleteConversationLocally(not_null<PeerData*> peer) { |
| 1536 | const auto markLeft = [&] { |
| 1537 | if (const auto channel = peer->asMegagroup()) { |
| 1538 | channel->addFlags(ChannelDataFlag::Left); |
| 1539 | if (const auto from = channel->getMigrateFromChat()) { |
| 1540 | if (const auto migrated = historyLoaded(from)) { |
| 1541 | migrated->updateChatListExistence(); |
| 1542 | } |
| 1543 | } |
| 1544 | } |
| 1545 | }; |
| 1546 | if (const auto history = historyLoaded(peer)) { |
| 1547 | if (history->folderKnown()) { |
| 1548 | setChatPinned(history, FilterId(), false); |
| 1549 | } |
| 1550 | removeChatListEntry(history); |
| 1551 | history->clearFolder(); |
| 1552 | |
| 1553 | // We want to mark the channel as left before unloading the history, |
| 1554 | // otherwise some parts of updating may return us to the chats list. |
| 1555 | markLeft(); |
| 1556 | history->clear(peer->isChannel() |
| 1557 | ? History::ClearType::Unload |
| 1558 | : History::ClearType::DeleteChat); |
| 1559 | } else { |
| 1560 | markLeft(); |
| 1561 | } |
| 1562 | } |
| 1563 | |
| 1564 | bool Session::chatsListLoaded(Data::Folder *folder) { |
| 1565 | return chatsList(folder)->loaded(); |
no test coverage detected