diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index a6acad90..17f1f257 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17733,13 +17733,15 @@ void MessagesManager::remove_message_notification(DialogId dialog_id, Notificati return; } - G()->td_db()->get_messages_db_async()->get_messages_from_notification_id( - dialog_id, NotificationId(notification_id.get() + 1), 1, - PromiseCreator::lambda( - [dialog_id, notification_id, actor_id = actor_id(this)](vector result) mutable { - send_closure(actor_id, &MessagesManager::do_remove_message_notification, dialog_id, notification_id, - std::move(result)); - })); + if (G()->parameters().use_message_db) { + G()->td_db()->get_messages_db_async()->get_messages_from_notification_id( + dialog_id, NotificationId(notification_id.get() + 1), 1, + PromiseCreator::lambda( + [dialog_id, notification_id, actor_id = actor_id(this)](vector result) mutable { + send_closure(actor_id, &MessagesManager::do_remove_message_notification, dialog_id, notification_id, + std::move(result)); + })); + } } void MessagesManager::do_remove_message_notification(DialogId dialog_id, NotificationId notification_id, @@ -17750,14 +17752,8 @@ void MessagesManager::do_remove_message_notification(DialogId dialog_id, Notific CHECK(result.size() == 1); Dialog *d = get_dialog_force(dialog_id); - if (d == nullptr) { - LOG(ERROR) << "Can't find " << dialog_id; - return; - } - if (!d->message_notification_group_id.is_valid()) { - LOG(ERROR) << "There is no message notiication group in " << dialog_id; - return; - } + CHECK(d != nullptr); + CHECK(d->message_notification_group_id.is_valid()); auto m = on_get_message_from_database(dialog_id, d, std::move(result[0])); if (m->notification_id == notification_id && is_message_has_active_notification(d, m)) { diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index d9918421..6a699e5c 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -244,6 +244,11 @@ int32 NotificationManager::load_message_notification_groups_from_database(int32 return result; } +void NotificationManager::load_message_notifications_from_database(const NotificationGroupKey &group_key, + const NotificationGroup &group) { + // TODO +} + size_t NotificationManager::get_max_notification_group_size() const { return max_notification_group_size_; } @@ -1151,7 +1156,7 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti added_notifications.pop_back(); } } else { - // TODO preload more notifications in the group + load_message_notifications_from_database(group_it->first, group_it->second); } } @@ -1388,8 +1393,8 @@ void NotificationManager::on_notification_group_size_max_changed() { } } if (new_max_notification_group_size_size_t > notification_count && - static_cast(group.total_count) > notification_count) { - // TODO load more notifications in the group from the message database + static_cast(group.total_count) > notification_count && G()->parameters().use_message_db) { + load_message_notifications_from_database(group_key, group); } if (added_notifications.empty()) { continue; diff --git a/td/telegram/NotificationManager.h b/td/telegram/NotificationManager.h index 396d5bc7..2bddc954 100644 --- a/td/telegram/NotificationManager.h +++ b/td/telegram/NotificationManager.h @@ -141,6 +141,8 @@ class NotificationManager : public Actor { int32 load_message_notification_groups_from_database(int32 limit, bool send_update); + void load_message_notifications_from_database(const NotificationGroupKey &group_key, const NotificationGroup &group); + NotificationGroupKey get_last_updated_group_key() const; void send_remove_group_update(const NotificationGroupKey &group_key, const NotificationGroup &group,