mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Fix starting with a passcode.
This commit is contained in:
parent
bc144377c0
commit
ba103fdd40
2 changed files with 38 additions and 36 deletions
|
@ -489,8 +489,8 @@ void Application::checkLocalTime() {
|
||||||
base::ConcurrentTimerEnvironment::Adjust();
|
base::ConcurrentTimerEnvironment::Adjust();
|
||||||
base::unixtime::http_invalidate();
|
base::unixtime::http_invalidate();
|
||||||
}
|
}
|
||||||
if (activeAccount().sessionExists()) {
|
if (const auto session = maybeActiveSession()) {
|
||||||
activeAccount().session().updates().checkLastUpdate(adjusted);
|
session->updates().checkLastUpdate(adjusted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,27 +575,36 @@ Main::Account &Application::activeAccount() const {
|
||||||
return _accounts->active();
|
return _accounts->active();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::exportPreventsQuit() {
|
Main::Session *Application::maybeActiveSession() const {
|
||||||
if (!activeAccount().sessionExists()
|
return (_accounts->started() && activeAccount().sessionExists())
|
||||||
|| !activeAccount().session().data().exportInProgress()) {
|
? &activeAccount().session()
|
||||||
return false;
|
: nullptr;
|
||||||
}
|
}
|
||||||
activeAccount().session().data().stopExportWithConfirmation([] {
|
|
||||||
|
bool Application::exportPreventsQuit() {
|
||||||
|
if (const auto session = maybeActiveSession()) {
|
||||||
|
if (session->data().exportInProgress()) {
|
||||||
|
session->data().stopExportWithConfirmation([] {
|
||||||
App::quit();
|
App::quit();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int Application::unreadBadge() const {
|
int Application::unreadBadge() const {
|
||||||
return (accounts().started() && activeAccount().sessionExists())
|
if (const auto session = maybeActiveSession()) {
|
||||||
? activeAccount().session().data().unreadBadge()
|
return session->data().unreadBadge();
|
||||||
: 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::unreadBadgeMuted() const {
|
bool Application::unreadBadgeMuted() const {
|
||||||
return (accounts().started() && activeAccount().sessionExists())
|
if (const auto session = maybeActiveSession()) {
|
||||||
? activeAccount().session().data().unreadBadgeMuted()
|
return session->data().unreadBadgeMuted();
|
||||||
: false;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::offerLegacyLangPackSwitch() const {
|
bool Application::offerLegacyLangPackSwitch() const {
|
||||||
|
@ -678,9 +687,8 @@ bool Application::openCustomUrl(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto command = urlTrimmed.midRef(protocol.size(), 8192);
|
const auto command = urlTrimmed.midRef(protocol.size(), 8192);
|
||||||
const auto session = activeAccount().sessionExists()
|
const auto session = maybeActiveSession();
|
||||||
? &activeAccount().session()
|
|
||||||
: nullptr;
|
|
||||||
using namespace qthelp;
|
using namespace qthelp;
|
||||||
const auto options = RegExOption::CaseInsensitive;
|
const auto options = RegExOption::CaseInsensitive;
|
||||||
for (const auto &[expression, handler] : handlers) {
|
for (const auto &[expression, handler] : handlers) {
|
||||||
|
@ -716,8 +724,8 @@ bool Application::passcodeLocked() const {
|
||||||
|
|
||||||
void Application::updateNonIdle() {
|
void Application::updateNonIdle() {
|
||||||
_lastNonIdleTime = crl::now();
|
_lastNonIdleTime = crl::now();
|
||||||
if (activeAccount().sessionExists()) {
|
if (const auto session = maybeActiveSession()) {
|
||||||
activeAccount().session().updates().checkIdleFinish();
|
session->updates().checkIdleFinish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,25 +953,18 @@ void Application::refreshGlobalProxy() {
|
||||||
|
|
||||||
void Application::QuitAttempt() {
|
void Application::QuitAttempt() {
|
||||||
auto prevents = false;
|
auto prevents = false;
|
||||||
if (IsAppLaunched()
|
if (IsAppLaunched() && !Sandbox::Instance().isSavingSession()) {
|
||||||
&& App().activeAccount().sessionExists()
|
if (const auto session = App().maybeActiveSession()) {
|
||||||
&& !Sandbox::Instance().isSavingSession()) {
|
if (session->updates().isQuitPrevent()
|
||||||
if (App().activeAccount().session().updates().isQuitPrevent()) {
|
|| session->api().isQuitPrevent()
|
||||||
prevents = true;
|
|| session->calls().isQuitPrevent()) {
|
||||||
}
|
|
||||||
if (App().activeAccount().session().api().isQuitPrevent()) {
|
|
||||||
prevents = true;
|
|
||||||
}
|
|
||||||
if (App().activeAccount().session().calls().isQuitPrevent()) {
|
|
||||||
prevents = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (prevents) {
|
|
||||||
App().quitDelayed();
|
App().quitDelayed();
|
||||||
} else {
|
return;
|
||||||
QApplication::quit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::quitPreventFinished() {
|
void Application::quitPreventFinished() {
|
||||||
if (App::quitting()) {
|
if (App::quitting()) {
|
||||||
|
|
|
@ -160,6 +160,7 @@ public:
|
||||||
[[nodiscard]] bool exportPreventsQuit();
|
[[nodiscard]] bool exportPreventsQuit();
|
||||||
|
|
||||||
// Main::Session component.
|
// Main::Session component.
|
||||||
|
Main::Session *maybeActiveSession() const;
|
||||||
[[nodiscard]] int unreadBadge() const;
|
[[nodiscard]] int unreadBadge() const;
|
||||||
[[nodiscard]] bool unreadBadgeMuted() const;
|
[[nodiscard]] bool unreadBadgeMuted() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue