2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Replace SingleTimer with base::Timer.

This commit is contained in:
John Preston
2019-01-18 15:26:43 +04:00
parent 61b9a32504
commit 314e30272b
66 changed files with 448 additions and 511 deletions

View File

@@ -33,14 +33,12 @@ constexpr auto kMinimalAlertDelay = TimeMs(500);
} // namespace
System::System(AuthSession *session) : _authSession(session) {
System::System(AuthSession *session)
: _authSession(session)
, _waitTimer([=] { showNext(); }) {
createManager();
_waitTimer.setTimeoutHandler([this] {
showNext();
});
subscribe(settingsChanged(), [this](ChangeType type) {
subscribe(settingsChanged(), [=](ChangeType type) {
if (type == ChangeType::DesktopEnabled) {
App::wnd()->updateTrayMenu();
clearAll();
@@ -124,7 +122,7 @@ void System::schedule(History *history, HistoryItem *item) {
}
if (haveSetting) {
if (!_waitTimer.isActive() || _waitTimer.remainingTime() > delay) {
_waitTimer.start(delay);
_waitTimer.callOnce(delay);
}
}
}
@@ -150,7 +148,7 @@ void System::clearFromHistory(History *history) {
_waiters.remove(history);
_settingWaiters.remove(history);
_waitTimer.stop();
_waitTimer.cancel();
showNext();
}
@@ -209,7 +207,7 @@ void System::checkDelayed() {
++i;
}
}
_waitTimer.stop();
_waitTimer.cancel();
showNext();
}
@@ -259,7 +257,7 @@ void System::showNext() {
if (_waiters.isEmpty() || !Global::DesktopNotify() || Platform::Notifications::SkipToast()) {
if (nextAlert) {
_waitTimer.start(nextAlert - ms);
_waitTimer.callOnce(nextAlert - ms);
}
return;
}
@@ -306,7 +304,7 @@ void System::showNext() {
next = nextAlert;
nextAlert = 0;
}
_waitTimer.start(next - ms);
_waitTimer.callOnce(next - ms);
break;
} else {
auto forwardedItem = notifyItem->Has<HistoryMessageForwarded>() ? notifyItem : nullptr; // forwarded notify grouping
@@ -366,7 +364,7 @@ void System::showNext() {
}
}
if (nextAlert) {
_waitTimer.start(nextAlert - ms);
_waitTimer.callOnce(nextAlert - ms);
}
}