tdesktop/Telegram/SourceFiles/api/api_global_privacy.h

63 lines
1.6 KiB
C
Raw Normal View History

2020-07-03 16:53:24 +00:00
/*
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"
class ApiWrap;
namespace Main {
class Session;
} // namespace Main
namespace Api {
2023-07-13 15:33:57 +00:00
enum class UnarchiveOnNewMessage {
None,
NotInFoldersUnmuted,
AnyUnmuted,
};
2020-07-03 16:53:24 +00:00
class GlobalPrivacy final {
public:
explicit GlobalPrivacy(not_null<ApiWrap*> api);
void reload(Fn<void()> callback = nullptr);
2023-08-11 14:20:38 +00:00
void updateArchiveAndMute(bool value);
void updateUnarchiveOnNewMessage(UnarchiveOnNewMessage value);
2020-07-03 16:53:24 +00:00
[[nodiscard]] bool archiveAndMuteCurrent() const;
[[nodiscard]] rpl::producer<bool> archiveAndMute() const;
2023-07-13 15:33:57 +00:00
[[nodiscard]] auto unarchiveOnNewMessageCurrent() const
-> UnarchiveOnNewMessage;
[[nodiscard]] auto unarchiveOnNewMessage() const
-> rpl::producer<UnarchiveOnNewMessage>;
2020-07-03 16:53:24 +00:00
[[nodiscard]] rpl::producer<bool> showArchiveAndMute() const;
[[nodiscard]] rpl::producer<> suggestArchiveAndMute() const;
void dismissArchiveAndMuteSuggestion();
private:
void apply(const MTPGlobalPrivacySettings &data);
2023-08-11 14:20:38 +00:00
void update(
bool archiveAndMute,
UnarchiveOnNewMessage unarchiveOnNewMessage);
2020-07-03 16:53:24 +00:00
const not_null<Main::Session*> _session;
MTP::Sender _api;
mtpRequestId _requestId = 0;
rpl::variable<bool> _archiveAndMute = false;
2023-07-13 15:33:57 +00:00
rpl::variable<UnarchiveOnNewMessage> _unarchiveOnNewMessage
= UnarchiveOnNewMessage::None;
2020-07-03 16:53:24 +00:00
rpl::variable<bool> _showArchiveAndMute = false;
std::vector<Fn<void()>> _callbacks;
2020-07-03 16:53:24 +00:00
};
} // namespace Api