From d9dcca77432ad2d4ee606b2be628ebff4dab58cb Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 2 Dec 2018 23:39:47 +0300 Subject: [PATCH] Send update about new loaded from database group. GitOrigin-RevId: d80f4746c36946eb9b5042c74b3c4ebdcefa876e --- td/telegram/MessagesManager.cpp | 3 +++ td/telegram/NotificationManager.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 2e69957b..67c08d70 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17681,6 +17681,9 @@ vector MessagesManager::get_message_notification_group_key return {}; } + VLOG(notifications) << "Load " << limit << " message notification groups from database from date " + << from_last_notification_date << " and " << from_dialog_id; + Result> r_dialogs = G()->td_db()->get_dialog_db_sync()->get_dialogs_by_last_notification_date(from_last_notification_date, from_dialog_id, limit); diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 5d5a3cf5..5ae8666d 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -202,7 +202,15 @@ NotificationManager::NotificationGroups::iterator NotificationManager::get_group VLOG(notifications) << "Finish to load " << group_id << " with total_count " << message_group.total_count << " and notifications " << group.notifications; - // TODO send update about the new group, if needed + if (send_update && group_key.last_notification_date != 0) { + auto last_group_key = get_last_updated_group_key(); + if (group_key < last_group_key) { + if (last_group_key.last_notification_date != 0) { + send_remove_group_update(last_group_key, groups_[last_group_key], vector()); + } + send_add_group_update(group_key, group); + } + } return add_group(std::move(group_key), std::move(group)); } @@ -218,6 +226,7 @@ int32 NotificationManager::load_message_notification_groups_from_database(int32 // everything was already loaded return 0; } + vector group_keys = td_->messages_manager_->get_message_notification_group_keys_from_database( last_loaded_notification_date_, last_loaded_notification_dialog_id_, limit); if (group_keys.empty()) {