2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Suggest enabling archive and mute in settings.

This commit is contained in:
John Preston
2020-07-06 18:08:28 +04:00
parent 152b49c65c
commit 5a1a8af222
5 changed files with 54 additions and 5 deletions

View File

@@ -19,7 +19,10 @@ GlobalPrivacy::GlobalPrivacy(not_null<ApiWrap*> api)
, _api(&api->instance()) {
}
void GlobalPrivacy::reload() {
void GlobalPrivacy::reload(Fn<void()> callback) {
if (callback) {
_callbacks.push_back(std::move(callback));
}
if (_requestId) {
return;
}
@@ -27,8 +30,14 @@ void GlobalPrivacy::reload() {
)).done([=](const MTPGlobalPrivacySettings &result) {
_requestId = 0;
apply(result);
for (const auto &callback : base::take(_callbacks)) {
callback();
}
}).fail([=](const RPCError &error) {
_requestId = 0;
for (const auto &callback : base::take(_callbacks)) {
callback();
}
}).send();
_session->account().appConfig().value(
@@ -36,7 +45,7 @@ void GlobalPrivacy::reload() {
_showArchiveAndMute = _session->account().appConfig().get<bool>(
u"autoarchive_setting_available"_q,
false);
}, _session->lifetime());
}, _session->lifetime());
}
bool GlobalPrivacy::archiveAndMuteCurrent() const {

View File

@@ -21,7 +21,7 @@ class GlobalPrivacy final {
public:
explicit GlobalPrivacy(not_null<ApiWrap*> api);
void reload();
void reload(Fn<void()> callback = nullptr);
void update(bool archiveAndMute);
[[nodiscard]] bool archiveAndMuteCurrent() const;
@@ -38,6 +38,7 @@ private:
mtpRequestId _requestId = 0;
rpl::variable<bool> _archiveAndMute = false;
rpl::variable<bool> _showArchiveAndMute = false;
std::vector<Fn<void()>> _callbacks;
};