From 015c5d83d02c2e9300ac799671fb4a237fe37751 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 6 Apr 2020 19:05:23 +0200 Subject: [PATCH] db: get last messages sorted by timestamp --- src/database.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database.c b/src/database.c index e3026ea1..340f59b2 100644 --- a/src/database.c +++ b/src/database.c @@ -212,7 +212,7 @@ log_database_get_previous_chat(const gchar *const contact_barejid) sqlite3_stmt *stmt = NULL; char *query; - if (asprintf(&query, "SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `id` ASC LIMIT 10", contact_barejid, contact_barejid) == -1) { + if (asprintf(&query, "SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` ASC LIMIT 10", contact_barejid, contact_barejid) == -1) { log_error("log_database_get_previous_chat(): SQL query. could not allocate memory"); return NULL; }