Use query_promise in GetContactSignUpNotificationQuery.
This commit is contained in:
parent
0225f0cab7
commit
552bde9fda
@ -94,10 +94,10 @@ class SetContactSignUpNotificationQuery final : public Td::ResultHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class GetContactSignUpNotificationQuery final : public Td::ResultHandler {
|
class GetContactSignUpNotificationQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<bool> promise_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GetContactSignUpNotificationQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit GetContactSignUpNotificationQuery(Promise<bool> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send() {
|
void send() {
|
||||||
@ -110,8 +110,7 @@ class GetContactSignUpNotificationQuery final : public Td::ResultHandler {
|
|||||||
return on_error(result_ptr.move_as_error());
|
return on_error(result_ptr.move_as_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->notification_manager_->on_get_disable_contact_registered_notifications(result_ptr.ok());
|
promise_.set_value(result_ptr.move_as_ok());
|
||||||
promise_.set_value(Unit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
@ -2575,9 +2574,9 @@ void NotificationManager::on_disable_contact_registered_notifications_changed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::on_get_disable_contact_registered_notifications(bool is_disabled) {
|
void NotificationManager::on_get_disable_contact_registered_notifications(bool is_disabled, Promise<Unit> &&promise) {
|
||||||
if (disable_contact_registered_notifications_ == is_disabled) {
|
if (G()->close_flag() || disable_contact_registered_notifications_ == is_disabled) {
|
||||||
return;
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
disable_contact_registered_notifications_ = is_disabled;
|
disable_contact_registered_notifications_ = is_disabled;
|
||||||
|
|
||||||
@ -2586,6 +2585,7 @@ void NotificationManager::on_get_disable_contact_registered_notifications(bool i
|
|||||||
} else {
|
} else {
|
||||||
G()->set_option_empty("disable_contact_registered_notifications");
|
G()->set_option_empty("disable_contact_registered_notifications");
|
||||||
}
|
}
|
||||||
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::set_contact_registered_notifications_sync_state(SyncState new_state) {
|
void NotificationManager::set_contact_registered_notifications_sync_state(SyncState new_state) {
|
||||||
@ -2642,7 +2642,16 @@ void NotificationManager::get_disable_contact_registered_notifications(Promise<U
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<GetContactSignUpNotificationQuery>(std::move(promise))->send();
|
auto query_promise =
|
||||||
|
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](Result<bool> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
send_closure(actor_id, &NotificationManager::on_get_disable_contact_registered_notifications, result.ok(),
|
||||||
|
std::move(promise));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
td_->create_handler<GetContactSignUpNotificationQuery>(std::move(query_promise))->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::process_push_notification(string payload, Promise<Unit> &&user_promise) {
|
void NotificationManager::process_push_notification(string payload, Promise<Unit> &&user_promise) {
|
||||||
|
@ -108,8 +108,6 @@ class NotificationManager final : public Actor {
|
|||||||
|
|
||||||
void on_disable_contact_registered_notifications_changed();
|
void on_disable_contact_registered_notifications_changed();
|
||||||
|
|
||||||
void on_get_disable_contact_registered_notifications(bool is_disabled);
|
|
||||||
|
|
||||||
void process_push_notification(string payload, Promise<Unit> &&user_promise);
|
void process_push_notification(string payload, Promise<Unit> &&user_promise);
|
||||||
|
|
||||||
static Result<int64> get_push_receiver_id(string payload);
|
static Result<int64> get_push_receiver_id(string payload);
|
||||||
@ -337,6 +335,8 @@ class NotificationManager final : public Actor {
|
|||||||
|
|
||||||
void on_contact_registered_notifications_sync(bool is_disabled, Result<Unit> result);
|
void on_contact_registered_notifications_sync(bool is_disabled, Result<Unit> result);
|
||||||
|
|
||||||
|
void on_get_disable_contact_registered_notifications(bool is_disabled, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void save_announcement_ids();
|
void save_announcement_ids();
|
||||||
|
|
||||||
static ActiveNotificationsUpdate as_active_notifications_update(const td_api::updateActiveNotifications *update);
|
static ActiveNotificationsUpdate as_active_notifications_update(const td_api::updateActiveNotifications *update);
|
||||||
|
Loading…
Reference in New Issue
Block a user