Move delete-from-ToS to AuthSession.

This commit is contained in:
John Preston 2019-03-27 12:37:25 +04:00
parent 3fa3428b4b
commit efb2972d28
5 changed files with 16 additions and 10 deletions

View File

@ -480,6 +480,12 @@ void AuthSession::localPasscodeChanged() {
checkAutoLock(); checkAutoLock();
} }
void AuthSession::termsDeleteNow() {
api().request(MTPaccount_DeleteAccount(
MTP_string("Decline ToS update")
)).send();
}
void AuthSession::checkAutoLock() { void AuthSession::checkAutoLock() {
if (!Global::LocalPasscode() if (!Global::LocalPasscode()
|| Core::App().passcodeLocked()) { || Core::App().passcodeLocked()) {

View File

@ -317,6 +317,7 @@ public:
void checkAutoLock(); void checkAutoLock();
void checkAutoLockIn(crl::time time); void checkAutoLockIn(crl::time time);
void localPasscodeChanged(); void localPasscodeChanged();
void termsDeleteNow();
rpl::lifetime &lifetime() { rpl::lifetime &lifetime() {
return _lifetime; return _lifetime;

View File

@ -898,10 +898,6 @@ rpl::producer<bool> Application::termsLockValue() const {
) | rpl::then(termsLockChanges()); ) | rpl::then(termsLockChanges());
} }
void Application::termsDeleteNow() {
MTP::send(MTPaccount_DeleteAccount(MTP_string("Decline ToS update")));
}
bool Application::locked() const { bool Application::locked() const {
return passcodeLocked() || termsLocked(); return passcodeLocked() || termsLocked();
} }

View File

@ -64,10 +64,7 @@ namespace Core {
class Launcher; class Launcher;
struct LocalUrlHandler; struct LocalUrlHandler;
class Application final class Application final : public QObject, private base::Subscriber {
: public QObject
, public RPCSender
, private base::Subscriber {
public: public:
Application(not_null<Launcher*> launcher); Application(not_null<Launcher*> launcher);
@ -188,7 +185,6 @@ public:
[[nodiscard]] std::optional<Window::TermsLock> termsLocked() const; [[nodiscard]] std::optional<Window::TermsLock> termsLocked() const;
rpl::producer<bool> termsLockChanges() const; rpl::producer<bool> termsLockChanges() const;
rpl::producer<bool> termsLockValue() const; rpl::producer<bool> termsLockValue() const;
void termsDeleteNow();
[[nodiscard]] bool locked() const; [[nodiscard]] bool locked() const;
rpl::producer<bool> lockChanges() const; rpl::producer<bool> lockChanges() const;

View File

@ -202,12 +202,19 @@ void MainWindow::showTermsDecline() {
void MainWindow::showTermsDelete() { void MainWindow::showTermsDelete() {
const auto box = std::make_shared<QPointer<BoxContent>>(); const auto box = std::make_shared<QPointer<BoxContent>>();
const auto deleteByTerms = [=] {
if (AuthSession::Exists()) {
Auth().termsDeleteNow();
} else {
Ui::hideLayer();
}
};
*box = Ui::show( *box = Ui::show(
Box<ConfirmBox>( Box<ConfirmBox>(
lang(lng_terms_delete_warning), lang(lng_terms_delete_warning),
lang(lng_terms_delete_now), lang(lng_terms_delete_now),
st::attentionBoxButton, st::attentionBoxButton,
[=] { Core::App().termsDeleteNow(); }, deleteByTerms,
[=] { if (*box) (*box)->closeBox(); }), [=] { if (*box) (*box)->closeBox(); }),
LayerOption::KeepOther); LayerOption::KeepOther);
} }