2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add 'Contact joined' notifications setting.

This commit is contained in:
John Preston
2019-01-18 13:24:10 +04:00
parent 01b7d4ffba
commit 61b9a32504
5 changed files with 99 additions and 5 deletions

View File

@@ -5225,12 +5225,54 @@ rpl::producer<Core::CloudPasswordState> ApiWrap::passwordState() const {
}
auto ApiWrap::passwordStateCurrent() const
->std::optional<Core::CloudPasswordState> {
-> std::optional<Core::CloudPasswordState> {
return _passwordState
? base::make_optional(*_passwordState)
: std::nullopt;
}
void ApiWrap::reloadContactSignupSilent() {
if (_contactSignupSilentRequestId) {
return;
}
const auto requestId = request(MTPaccount_GetContactSignUpNotification(
)).done([=](const MTPBool &result) {
_contactSignupSilentRequestId = 0;
const auto silent = mtpIsTrue(result);
_contactSignupSilent = silent;
_contactSignupSilentChanges.fire_copy(silent);
}).fail([=](const RPCError &error) {
_contactSignupSilentRequestId = 0;
}).send();
_contactSignupSilentRequestId = requestId;
}
rpl::producer<bool> ApiWrap::contactSignupSilent() const {
return _contactSignupSilent
? _contactSignupSilentChanges.events_starting_with_copy(
*_contactSignupSilent)
: (_contactSignupSilentChanges.events() | rpl::type_erased());
}
std::optional<bool> ApiWrap::contactSignupSilentCurrent() const {
return _contactSignupSilent;
}
void ApiWrap::saveContactSignupSilent(bool silent) {
request(base::take(_contactSignupSilentRequestId)).cancel();
const auto requestId = request(MTPaccount_SetContactSignUpNotification(
MTP_bool(silent)
)).done([=](const MTPBool &) {
_contactSignupSilentRequestId = 0;
_contactSignupSilent = silent;
_contactSignupSilentChanges.fire_copy(silent);
}).fail([=](const RPCError &error) {
_contactSignupSilentRequestId = 0;
}).send();
_contactSignupSilentRequestId = requestId;
}
void ApiWrap::saveSelfBio(const QString &text, FnMut<void()> done) {
if (_saveBioRequestId) {
if (text != _saveBioText) {