From fb4f82b82c81a9b05be8709f41602c8711f1cae9 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 6 Apr 2020 19:44:03 +0200 Subject: [PATCH] db: actually display the last 10 entries in correct order --- src/database.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database.c b/src/database.c index 340f59b2..714c4b1a 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 `timestamp` ASC LIMIT 10", contact_barejid, contact_barejid) == -1) { + if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, contact_barejid) == -1) { log_error("log_database_get_previous_chat(): SQL query. could not allocate memory"); return NULL; }