Fixed updating number of sessions after terminating any of them.

This commit is contained in:
23rd 2021-02-17 01:25:57 +03:00
parent bff3291631
commit c3c1759f3c
2 changed files with 17 additions and 7 deletions

View file

@ -128,9 +128,19 @@ void Authorizations::requestTerminate(
const auto send = [&](auto request) { const auto send = [&](auto request) {
_api.request( _api.request(
std::move(request) std::move(request)
).done( ).done([=, done = std::move(done)](const MTPBool &result) {
std::move(done) done(result);
).fail( if (mtpIsTrue(result)) {
if (hash) {
_list.erase(
ranges::remove(_list, *hash, &Entry::hash),
end(_list));
} else {
_list.clear();
}
_listChanges.fire({});
}
}).fail(
std::move(fail) std::move(fail)
).send(); ).send();
}; };

View file

@ -262,13 +262,13 @@ void SessionsContent::terminateOne(uint64 hash) {
const auto weak = Ui::MakeWeak(this); const auto weak = Ui::MakeWeak(this);
auto callback = [=] { auto callback = [=] {
auto done = crl::guard(weak, [=](const MTPBool &result) { auto done = crl::guard(weak, [=](const MTPBool &result) {
if (mtpIsFalse(result)) {
return;
}
_inner->terminatingOne(hash, false); _inner->terminatingOne(hash, false);
const auto getHash = [](const Entry &entry) {
return entry.hash;
};
const auto removeByHash = [&](std::vector<Entry> &list) { const auto removeByHash = [&](std::vector<Entry> &list) {
list.erase( list.erase(
ranges::remove(list, hash, getHash), ranges::remove(list, hash, &Entry::hash),
end(list)); end(list));
}; };
removeByHash(_data.incomplete); removeByHash(_data.incomplete);