From 82d78e7c452a4978c3eea535a80fe876ef09ddaa Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 25 Jan 2021 01:00:01 +0400 Subject: [PATCH] Decrease indentation in notification manager creation --- .../linux/notifications_manager_linux.cpp | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index a13918362..9effa1964 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -718,39 +718,42 @@ void Create(Window::Notifications::System *system) { } }; + if (!ServiceRegistered) { + CurrentServerInformation = std::nullopt; + CurrentCapabilities = QStringList{}; + InhibitionSupported = false; + managerSetter(); + return; + } + + // There are some asserts that manager is not nullptr, + // avoid crashes until some real manager is created if (!system->managerType().has_value()) { using DummyManager = Window::Notifications::DummyManager; system->setManager(std::make_unique(system)); } - if (ServiceRegistered) { - const auto counter = std::make_shared(3); - const auto oneReady = [=] { - if (!--*counter) { - managerSetter(); - } - }; + const auto counter = std::make_shared(3); + const auto oneReady = [=] { + if (!--*counter) { + managerSetter(); + } + }; - GetServerInformation([=](std::optional result) { - CurrentServerInformation = result; - oneReady(); - }); + GetServerInformation([=](std::optional result) { + CurrentServerInformation = result; + oneReady(); + }); - GetCapabilities([=](QStringList result) { - CurrentCapabilities = result; - oneReady(); - }); + GetCapabilities([=](QStringList result) { + CurrentCapabilities = result; + oneReady(); + }); - GetInhibitionSupported([=](bool result) { - InhibitionSupported = result; - oneReady(); - }); - } else { - CurrentServerInformation = std::nullopt; - CurrentCapabilities = QStringList{}; - InhibitionSupported = false; - managerSetter(); - } + GetInhibitionSupported([=](bool result) { + InhibitionSupported = result; + oneReady(); + }); } class Manager::Private {