mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-28 09:32:56 +00:00
Create notifications manager after reading settings.
This commit is contained in:
parent
0db6fc4ffb
commit
c3fa300b5c
@ -183,6 +183,7 @@ void Application::run() {
|
||||
refreshGlobalProxy(); // Depends on Global::start().
|
||||
|
||||
// Depends on OpenSSL on macOS, so on ThirdParty::start().
|
||||
// Depends on notifications settings.
|
||||
_notifications = std::make_unique<Window::Notifications::System>();
|
||||
|
||||
startLocalStorage();
|
||||
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "storage/storage_account.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "export/export_settings.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "facades.h"
|
||||
|
||||
namespace Main {
|
||||
@ -28,6 +29,7 @@ Domain::Domain(const QString &dataName)
|
||||
_active.changes(
|
||||
) | rpl::take(1) | rpl::start_with_next([] {
|
||||
Local::rewriteSettingsIfNeeded();
|
||||
Core::App().notifications().createManager();
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,6 @@ constexpr auto kSystemAlertDuration = crl::time(0);
|
||||
System::System()
|
||||
: _waitTimer([=] { showNext(); })
|
||||
, _waitForAllGroupedTimer([=] { showGrouped(); }) {
|
||||
createManager();
|
||||
|
||||
subscribe(settingsChanged(), [=](ChangeType type) {
|
||||
if (type == ChangeType::DesktopEnabled) {
|
||||
App::wnd()->updateTrayMenu();
|
||||
@ -174,7 +172,9 @@ void System::schedule(not_null<HistoryItem*> item) {
|
||||
}
|
||||
|
||||
void System::clearAll() {
|
||||
_manager->clearAll();
|
||||
if (_manager) {
|
||||
_manager->clearAll();
|
||||
}
|
||||
|
||||
for (auto i = _whenMaps.cbegin(), e = _whenMaps.cend(); i != e; ++i) {
|
||||
i->first->clearNotifications();
|
||||
@ -186,7 +186,9 @@ void System::clearAll() {
|
||||
}
|
||||
|
||||
void System::clearFromHistory(not_null<History*> history) {
|
||||
_manager->clearFromHistory(history);
|
||||
if (_manager) {
|
||||
_manager->clearFromHistory(history);
|
||||
}
|
||||
|
||||
history->clearNotifications();
|
||||
_whenMaps.remove(history);
|
||||
@ -199,7 +201,9 @@ void System::clearFromHistory(not_null<History*> history) {
|
||||
}
|
||||
|
||||
void System::clearFromSession(not_null<Main::Session*> session) {
|
||||
_manager->clearFromSession(session);
|
||||
if (_manager) {
|
||||
_manager->clearFromSession(session);
|
||||
}
|
||||
|
||||
for (auto i = _whenMaps.begin(); i != _whenMaps.end();) {
|
||||
const auto history = i->first;
|
||||
@ -228,17 +232,23 @@ void System::clearFromSession(not_null<Main::Session*> session) {
|
||||
}
|
||||
|
||||
void System::clearIncomingFromHistory(not_null<History*> history) {
|
||||
_manager->clearFromHistory(history);
|
||||
if (_manager) {
|
||||
_manager->clearFromHistory(history);
|
||||
}
|
||||
history->clearIncomingNotifications();
|
||||
_whenAlerts.remove(history);
|
||||
}
|
||||
|
||||
void System::clearFromItem(not_null<HistoryItem*> item) {
|
||||
_manager->clearFromItem(item);
|
||||
if (_manager) {
|
||||
_manager->clearFromItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void System::clearAllFast() {
|
||||
_manager->clearAllFast();
|
||||
if (_manager) {
|
||||
_manager->clearAllFast();
|
||||
}
|
||||
|
||||
_whenMaps.clear();
|
||||
_whenAlerts.clear();
|
||||
@ -293,6 +303,8 @@ void System::checkDelayed() {
|
||||
}
|
||||
|
||||
void System::showGrouped() {
|
||||
Expects(_manager != nullptr);
|
||||
|
||||
if (const auto session = findSession(_lastHistorySessionId)) {
|
||||
if (const auto lastItem = session->data().message(_lastHistoryItemId)) {
|
||||
_waitForAllGroupedTimer.cancel();
|
||||
@ -305,7 +317,11 @@ void System::showGrouped() {
|
||||
}
|
||||
|
||||
void System::showNext() {
|
||||
if (App::quitting()) return;
|
||||
Expects(_manager != nullptr);
|
||||
|
||||
if (App::quitting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto isSameGroup = [=](HistoryItem *item) {
|
||||
if (!_lastHistorySessionId || !_lastHistoryItemId || !item) {
|
||||
@ -536,7 +552,9 @@ void System::ensureSoundCreated() {
|
||||
}
|
||||
|
||||
void System::updateAll() {
|
||||
_manager->updateAll();
|
||||
if (_manager) {
|
||||
_manager->updateAll();
|
||||
}
|
||||
}
|
||||
|
||||
Manager::DisplayOptions Manager::GetNotificationOptions(HistoryItem *item) {
|
||||
|
Loading…
Reference in New Issue
Block a user