/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "mtproto/sender.h" namespace Main { class Account; class AppConfig final { public: explicit AppConfig(not_null account); template [[nodiscard]] Type get(const QString &key, Type fallback) const { if constexpr (std::is_same_v) { return getDouble(key, fallback); } else if constexpr (std::is_same_v) { return getString(key, fallback); } else if constexpr (std::is_same_v>) { return getStringArray(key, std::move(fallback)); } else if constexpr (std::is_same_v>>) { return getStringMapArray(key, std::move(fallback)); } else if constexpr (std::is_same_v) { return getBool(key, fallback); } } [[nodiscard]] rpl::producer<> refreshed() const; [[nodiscard]] rpl::producer<> value() const; [[nodiscard]] bool suggestionCurrent(const QString &key) const; [[nodiscard]] rpl::producer<> suggestionRequested( const QString &key) const; void dismissSuggestion(const QString &key); void refresh(); private: void refreshDelayed(); template [[nodiscard]] auto getValue( const QString &key, Extractor &&extractor) const; [[nodiscard]] bool getBool( const QString &key, bool fallback) const; [[nodiscard]] double getDouble( const QString &key, double fallback) const; [[nodiscard]] QString getString( const QString &key, const QString &fallback) const; [[nodiscard]] std::vector getStringArray( const QString &key, std::vector &&fallback) const; [[nodiscard]] std::vector> getStringMapArray( const QString &key, std::vector> &&fallback) const; const not_null _account; std::optional _api; mtpRequestId _requestId = 0; base::flat_map _data; rpl::event_stream<> _refreshed; base::flat_set _dismissedSuggestions; rpl::lifetime _lifetime; }; } // namespace Main