diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 769b00543..8448b1f2e 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -12,6 +12,7 @@ #include "td/telegram/DeviceTokenManager.h" #include "td/telegram/Global.h" #include "td/telegram/MessagesManager.h" +#include "td/telegram/StateManager.h" #include "td/telegram/Td.h" #include "td/telegram/TdDb.h" @@ -150,6 +151,22 @@ void NotificationManager::start_up() { available_call_notification_group_ids_.insert(group_id); } } + + class StateCallback : public StateManager::Callback { + public: + explicit StateCallback(ActorId parent) : parent_(std::move(parent)) { + } + bool on_online(bool is_online) override { + if (is_online) { + send_closure(parent_, &NotificationManager::flush_all_pending_notifications); + } + return parent_.is_alive(); + } + + private: + ActorId parent_; + }; + send_closure(G()->state_manager(), &StateManager::add_callback, make_unique(actor_id(this))); } td_api::object_ptr NotificationManager::get_update_active_notifications() const {