From 3a021f4e4940d4f971f9a88f1f8b90220e25d5fd Mon Sep 17 00:00:00 2001 From: CrisMystik <62919067+CrisMystik@users.noreply.github.com> Date: Mon, 25 Apr 2022 21:16:39 +0200 Subject: [PATCH] Make type variable const --- .../SourceFiles/core/local_url_handlers.cpp | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 7fa146eeb6..2803307d0f 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -447,27 +447,31 @@ bool ResolveSettings( } controller->window().activate(); const auto section = match->captured(1).mid(1).toLower(); - auto type = ::Settings::Main::Id(); - if (section.isEmpty()) { - controller->window().showSettings(); - return true; - } else if (section == qstr("language")) { - ShowLanguagesBox(); - return true; - } else if (section == qstr("devices")) { - controller->session().api().authorizations().reload(); - type = ::Settings::Sessions::Id(); - } else if (section == qstr("folders")) { - type = ::Settings::Folders::Id(); - } else if (section == qstr("privacy")) { - type = ::Settings::PrivacySecurity::Id(); - } else if (section == qstr("themes")) { - type = ::Settings::Chat::Id(); - } else if (section == qstr("change_number")) { - type = ::Settings::ChangePhone::Id(); + + const auto getSectionType = [&]() -> std::optional<::Settings::Type> { + if (section.isEmpty()) { + return ::Settings::Main::Id(); + } else if (section == qstr("language")) { + ShowLanguagesBox(); + } else if (section == qstr("devices")) { + controller->session().api().authorizations().reload(); + return ::Settings::Sessions::Id(); + } else if (section == qstr("folders")) { + return ::Settings::Folders::Id(); + } else if (section == qstr("privacy")) { + return ::Settings::PrivacySecurity::Id(); + } else if (section == qstr("themes")) { + return ::Settings::Chat::Id(); + } else if (section == qstr("change_number")) { + return ::Settings::ChangePhone::Id(); + } + return {}; + }; + + if (const auto type = getSectionType()) { + controller->showSettings(*type); + controller->window().activate(); } - controller->showSettings(type); - controller->window().activate(); return true; }