From fca9995f1fd9c1fa09ba024f8d0eeb417d97b9ee Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Tue, 10 Dec 2019 15:42:49 +0200 Subject: [PATCH] fix: Ordering in latestMessageTimestamps --- packages/daf-data-store/src/data-store.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/daf-data-store/src/data-store.ts b/packages/daf-data-store/src/data-store.ts index d3bf7d25d..bb1a7cddf 100644 --- a/packages/daf-data-store/src/data-store.ts +++ b/packages/daf-data-store/src/data-store.ts @@ -258,8 +258,8 @@ export class DataStore { } async latestMessageTimestamps() { - let query = `SELECT * FROM ( SELECT m.id, m."timestamp", m.sender AS did, md. "type" AS sourceType, md.id AS sourceId FROM messages AS m - LEFT JOIN messages_meta_data AS md ON m.id = md.message_id) GROUP BY did, sourceType` + let query = `SELECT * FROM ( SELECT m.id, m."timestamp", m.receiver AS did, md. "type" AS sourceType, md.id AS sourceId FROM messages AS m + LEFT JOIN messages_meta_data AS md ON m.id = md.message_id order by m.timestamp desc) GROUP BY did, sourceType` return await this.db.rows(query, []) }