api_sensitive_content.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "mtproto/sender.h"
  9. #include "base/timer.h"
  10. class ApiWrap;
  11. namespace Main {
  12. class Session;
  13. } // namespace Main
  14. namespace Api {
  15. class SensitiveContent final {
  16. public:
  17. explicit SensitiveContent(not_null<ApiWrap*> api);
  18. void preload();
  19. void reload(bool force = false);
  20. void update(bool enabled);
  21. [[nodiscard]] bool enabledCurrent() const;
  22. [[nodiscard]] rpl::producer<bool> enabled() const;
  23. [[nodiscard]] rpl::producer<bool> canChange() const;
  24. private:
  25. const not_null<Main::Session*> _session;
  26. MTP::Sender _api;
  27. mtpRequestId _loadRequestId = 0;
  28. mtpRequestId _saveRequestId = 0;
  29. rpl::variable<bool> _enabled = false;
  30. rpl::variable<bool> _canChange = false;
  31. base::Timer _appConfigReloadTimer;
  32. bool _appConfigReloadForce = false;
  33. bool _loadPending = false;
  34. bool _loaded = false;
  35. };
  36. } // namespace Api