2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Fix unpinning all messages.

This commit is contained in:
John Preston
2020-10-30 17:12:04 +03:00
parent b7319c00b9
commit 0687cea1ed
3 changed files with 18 additions and 7 deletions

View File

@@ -1182,20 +1182,16 @@ void UnpinAllMessages(
Ui::show(Box<ConfirmBox>(tr::lng_pinned_unpin_all_sure(tr::now), tr::lng_pinned_unpin(tr::now), crl::guard(navigation, [=] {
Ui::hideLayer();
const auto api = &history->session().api();
const auto peer = history->peer;
const auto sendRequest = [=](auto self) -> void {
api->request(MTPmessages_UnpinAllMessages(
peer->input
history->peer->input
)).done([=](const MTPmessages_AffectedHistory &result) {
const auto peer = history->peer;
const auto offset = api->applyAffectedHistory(peer, result);
if (offset > 0) {
self(self);
} else {
peer->session().storage().remove(
Storage::SharedMediaRemoveAll(
peer->id,
Storage::SharedMediaType::Pinned));
peer->setHasPinnedMessages(false);
history->unpinAllMessages();
}
}).send();
};