2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Remove supergroup migrate messages.

This commit is contained in:
John Preston
2019-01-15 15:57:45 +04:00
parent c552db04d7
commit 2a0b9a44dd
40 changed files with 695 additions and 481 deletions

View File

@@ -605,25 +605,26 @@ void DeleteMessagesBox::deleteAndClear() {
_deleteConfirmedCallback();
}
QMap<PeerData*, QVector<MTPint>> idsByPeer;
base::flat_map<not_null<PeerData*>, QVector<MTPint>> idsByPeer;
for (const auto itemId : _ids) {
if (auto item = App::histItemById(itemId)) {
auto history = item->history();
auto wasOnServer = (item->id > 0);
auto wasLast = (history->lastMessage() == item);
if (const auto item = App::histItemById(itemId)) {
const auto history = item->history();
const auto wasOnServer = IsServerMsgId(item->id);
const auto wasLast = (history->lastMessage() == item);
const auto wasInChats = (history->chatListMessage() == item);
item->destroy();
if (wasOnServer) {
idsByPeer[history->peer].push_back(MTP_int(itemId.msg));
} else if (wasLast && !history->lastMessageKnown()) {
history->session().api().requestDialogEntry(history);
} else if (wasLast || wasInChats) {
history->requestChatListMessage();
}
}
}
auto forEveryone = _forEveryone ? _forEveryone->checked() : false;
for (auto i = idsByPeer.cbegin(), e = idsByPeer.cend(); i != e; ++i) {
App::main()->deleteMessages(i.key(), i.value(), forEveryone);
const auto revoke = _forEveryone ? _forEveryone->checked() : false;
for (const auto &[peer, ids] : idsByPeer) {
App::main()->deleteMessages(peer, ids, revoke);
}
Ui::hideLayer();
Auth().data().sendHistoryChangeNotifications();