mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Fix crash on quit in idle state.
This commit is contained in:
parent
9144f4ea7b
commit
f7454a4284
3 changed files with 18 additions and 7 deletions
|
@ -867,7 +867,11 @@ void Updates::updateOnline() {
|
|||
}
|
||||
|
||||
bool Updates::isIdle() const {
|
||||
return _isIdle;
|
||||
return _isIdle.current();
|
||||
}
|
||||
|
||||
rpl::producer<bool> Updates::isIdleValue() const {
|
||||
return _isIdle.value();
|
||||
}
|
||||
|
||||
void Updates::updateOnline(bool gotOtherOffline) {
|
||||
|
@ -881,7 +885,7 @@ void Updates::updateOnline(bool gotOtherOffline) {
|
|||
const auto idle = crl::now() - Core::App().lastNonIdleTime();
|
||||
if (idle >= config.offlineIdleTimeout) {
|
||||
isOnline = false;
|
||||
if (!_isIdle) {
|
||||
if (!isIdle()) {
|
||||
_isIdle = true;
|
||||
_idleFinishTimer.callOnce(900);
|
||||
}
|
||||
|
@ -932,10 +936,9 @@ void Updates::updateOnline(bool gotOtherOffline) {
|
|||
void Updates::checkIdleFinish() {
|
||||
if (crl::now() - Core::App().lastNonIdleTime()
|
||||
< _session->serverConfig().offlineIdleTimeout) {
|
||||
updateOnline();
|
||||
_idleFinishTimer.cancel();
|
||||
_isIdle = false;
|
||||
updateOnline();
|
||||
App::wnd()->checkHistoryActivation();
|
||||
} else {
|
||||
_idleFinishTimer.callOnce(900);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
|
||||
void updateOnline();
|
||||
[[nodiscard]] bool isIdle() const;
|
||||
[[nodiscard]] rpl::producer<bool> isIdleValue() const;
|
||||
void checkIdleFinish();
|
||||
bool lastWasOnline() const;
|
||||
crl::time lastSetOnline() const;
|
||||
|
@ -185,7 +186,7 @@ private:
|
|||
base::Timer _idleFinishTimer;
|
||||
crl::time _lastSetOnline = 0;
|
||||
bool _lastWasOnline = false;
|
||||
bool _isIdle = false;
|
||||
rpl::variable<bool> _isIdle = false;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void Controller::showAccount(not_null<Main::Account*> account) {
|
|||
_sessionController->filtersMenuChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
sideBarChanged();
|
||||
}, session->lifetime());
|
||||
}, _sessionController->lifetime());
|
||||
}
|
||||
if (session && session->settings().dialogsFiltersEnabled()) {
|
||||
_sessionController->toggleFiltersMenu(true);
|
||||
|
@ -93,11 +93,18 @@ void Controller::showAccount(not_null<Main::Account*> account) {
|
|||
if (session) {
|
||||
setupMain();
|
||||
|
||||
session->updates().isIdleValue(
|
||||
) | rpl::filter([=](bool idle) {
|
||||
return !idle;
|
||||
}) | rpl::start_with_next([=] {
|
||||
widget()->checkHistoryActivation();
|
||||
}, _sessionController->lifetime());
|
||||
|
||||
session->termsLockValue(
|
||||
) | rpl::start_with_next([=] {
|
||||
checkLockByTerms();
|
||||
_widget.updateGlobalMenu();
|
||||
}, _lifetime);
|
||||
}, _sessionController->lifetime());
|
||||
} else {
|
||||
setupIntro();
|
||||
_widget.updateGlobalMenu();
|
||||
|
|
Loading…
Add table
Reference in a new issue