mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Moved same parts of code of terminating in SessionsBox to single place.
This commit is contained in:
parent
8d2cacac80
commit
6b7c33f0ee
2 changed files with 23 additions and 24 deletions
|
@ -286,13 +286,28 @@ void SessionsBox::shortPollSessions() {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionsBox::terminateOne(uint64 hash) {
|
void SessionsBox::terminate(Fn<void()> terminateRequest, QString message) {
|
||||||
if (_terminateBox) _terminateBox->deleteLater();
|
if (_terminateBox) {
|
||||||
|
_terminateBox->deleteLater();
|
||||||
|
}
|
||||||
const auto callback = crl::guard(this, [=] {
|
const auto callback = crl::guard(this, [=] {
|
||||||
if (_terminateBox) {
|
if (_terminateBox) {
|
||||||
_terminateBox->closeBox();
|
_terminateBox->closeBox();
|
||||||
_terminateBox = nullptr;
|
_terminateBox = nullptr;
|
||||||
}
|
}
|
||||||
|
terminateRequest();
|
||||||
|
});
|
||||||
|
_terminateBox = Ui::show(
|
||||||
|
Box<ConfirmBox>(
|
||||||
|
message,
|
||||||
|
tr::lng_settings_reset_button(tr::now),
|
||||||
|
st::attentionBoxButton,
|
||||||
|
callback),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionsBox::terminateOne(uint64 hash) {
|
||||||
|
auto callback = [=] {
|
||||||
_api.request(MTPaccount_ResetAuthorization(
|
_api.request(MTPaccount_ResetAuthorization(
|
||||||
MTP_long(hash)
|
MTP_long(hash)
|
||||||
)).done([=](const MTPBool &result) {
|
)).done([=](const MTPBool &result) {
|
||||||
|
@ -312,23 +327,12 @@ void SessionsBox::terminateOne(uint64 hash) {
|
||||||
_inner->terminatingOne(hash, false);
|
_inner->terminatingOne(hash, false);
|
||||||
}).send();
|
}).send();
|
||||||
_inner->terminatingOne(hash, true);
|
_inner->terminatingOne(hash, true);
|
||||||
});
|
};
|
||||||
_terminateBox = Ui::show(
|
terminate(std::move(callback), tr::lng_settings_reset_one_sure(tr::now));
|
||||||
Box<ConfirmBox>(
|
|
||||||
tr::lng_settings_reset_one_sure(tr::now),
|
|
||||||
tr::lng_settings_reset_button(tr::now),
|
|
||||||
st::attentionBoxButton,
|
|
||||||
callback),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionsBox::terminateAll() {
|
void SessionsBox::terminateAll() {
|
||||||
if (_terminateBox) _terminateBox->deleteLater();
|
auto callback = [=] {
|
||||||
const auto callback = crl::guard(this, [=] {
|
|
||||||
if (_terminateBox) {
|
|
||||||
_terminateBox->closeBox();
|
|
||||||
_terminateBox = nullptr;
|
|
||||||
}
|
|
||||||
_api.request(MTPauth_ResetAuthorizations(
|
_api.request(MTPauth_ResetAuthorizations(
|
||||||
)).done([=](const MTPBool &result) {
|
)).done([=](const MTPBool &result) {
|
||||||
_api.request(base::take(_shortPollRequest)).cancel();
|
_api.request(base::take(_shortPollRequest)).cancel();
|
||||||
|
@ -338,14 +342,8 @@ void SessionsBox::terminateAll() {
|
||||||
shortPollSessions();
|
shortPollSessions();
|
||||||
}).send();
|
}).send();
|
||||||
_loading = true;
|
_loading = true;
|
||||||
});
|
};
|
||||||
_terminateBox = Ui::show(
|
terminate(std::move(callback), tr::lng_settings_reset_sure(tr::now));
|
||||||
Box<ConfirmBox>(
|
|
||||||
tr::lng_settings_reset_sure(tr::now),
|
|
||||||
tr::lng_settings_reset_button(tr::now),
|
|
||||||
st::attentionBoxButton,
|
|
||||||
callback),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionsBox::Inner::Inner(QWidget *parent)
|
SessionsBox::Inner::Inner(QWidget *parent)
|
||||||
|
|
|
@ -55,6 +55,7 @@ private:
|
||||||
|
|
||||||
void got(const MTPaccount_Authorizations &result);
|
void got(const MTPaccount_Authorizations &result);
|
||||||
|
|
||||||
|
void terminate(Fn<void()> terminateRequest, QString message);
|
||||||
void terminateOne(uint64 hash);
|
void terminateOne(uint64 hash);
|
||||||
void terminateAll();
|
void terminateAll();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue