diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index 305c674865..cd2388deb6 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -480,6 +480,12 @@ void AuthSession::localPasscodeChanged() { checkAutoLock(); } +void AuthSession::termsDeleteNow() { + api().request(MTPaccount_DeleteAccount( + MTP_string("Decline ToS update") + )).send(); +} + void AuthSession::checkAutoLock() { if (!Global::LocalPasscode() || Core::App().passcodeLocked()) { diff --git a/Telegram/SourceFiles/auth_session.h b/Telegram/SourceFiles/auth_session.h index aa7fc789ff..2a589f8ecc 100644 --- a/Telegram/SourceFiles/auth_session.h +++ b/Telegram/SourceFiles/auth_session.h @@ -317,6 +317,7 @@ public: void checkAutoLock(); void checkAutoLockIn(crl::time time); void localPasscodeChanged(); + void termsDeleteNow(); rpl::lifetime &lifetime() { return _lifetime; diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index ff9745db82..66687edaa0 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -898,10 +898,6 @@ rpl::producer Application::termsLockValue() const { ) | rpl::then(termsLockChanges()); } -void Application::termsDeleteNow() { - MTP::send(MTPaccount_DeleteAccount(MTP_string("Decline ToS update"))); -} - bool Application::locked() const { return passcodeLocked() || termsLocked(); } diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 7492c48d4f..9ab7579e12 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -64,10 +64,7 @@ namespace Core { class Launcher; struct LocalUrlHandler; -class Application final - : public QObject - , public RPCSender - , private base::Subscriber { +class Application final : public QObject, private base::Subscriber { public: Application(not_null launcher); @@ -188,7 +185,6 @@ public: [[nodiscard]] std::optional termsLocked() const; rpl::producer termsLockChanges() const; rpl::producer termsLockValue() const; - void termsDeleteNow(); [[nodiscard]] bool locked() const; rpl::producer lockChanges() const; diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index e69b78a803..af296e3c16 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -202,12 +202,19 @@ void MainWindow::showTermsDecline() { void MainWindow::showTermsDelete() { const auto box = std::make_shared>(); + const auto deleteByTerms = [=] { + if (AuthSession::Exists()) { + Auth().termsDeleteNow(); + } else { + Ui::hideLayer(); + } + }; *box = Ui::show( Box( lang(lng_terms_delete_warning), lang(lng_terms_delete_now), st::attentionBoxButton, - [=] { Core::App().termsDeleteNow(); }, + deleteByTerms, [=] { if (*box) (*box)->closeBox(); }), LayerOption::KeepOther); }