From 915b9c70a58c9d9b09a40bed25dffee420dbb24f Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 7 Jan 2019 06:23:42 +0300 Subject: [PATCH] Fix loading last_notification_date from database. GitOrigin-RevId: 6d1d268bee58a49179e4d02b178dd7c116a46556 --- td/telegram/DialogDb.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/td/telegram/DialogDb.cpp b/td/telegram/DialogDb.cpp index 18ebacc25..3eb309f4f 100644 --- a/td/telegram/DialogDb.cpp +++ b/td/telegram/DialogDb.cpp @@ -176,7 +176,7 @@ class DialogDbImpl : public DialogDbSyncInterface { return Status::Error("Not found"); } return NotificationGroupKey(notification_group_id, DialogId(get_notification_group_stmt_.view_int64(0)), - get_notification_group_stmt_.view_int32(1)); + get_last_notification_date(get_notification_group_stmt_, 1)); } Result> get_dialogs(int64 order, DialogId dialog_id, int32 limit) override { @@ -217,7 +217,7 @@ class DialogDbImpl : public DialogDbSyncInterface { TRY_STATUS(stmt.step()); while (stmt.has_row()) { notification_groups.emplace_back(NotificationGroupId(stmt.view_int32(0)), DialogId(stmt.view_int64(1)), - stmt.view_int32(2)); + get_last_notification_date(stmt, 2)); TRY_STATUS(stmt.step()); } @@ -239,6 +239,13 @@ class DialogDbImpl : public DialogDbSyncInterface { SqliteStatement get_dialogs_stmt_; SqliteStatement get_notification_groups_by_last_notification_date_stmt_; SqliteStatement get_notification_group_stmt_; + + static int32 get_last_notification_date(SqliteStatement &stmt, int id) { + if (stmt.view_datatype(id) == SqliteStatement::Datatype::Null) { + return 0; + } + return stmt.view_int32(id); + } }; std::shared_ptr create_dialog_db_sync(