From 24d4276a7c3b84f72dd063d653a453fca7dabdc7 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 28 Apr 2020 17:45:27 +0300 Subject: [PATCH] Fix msg id order when loading from sqlite --- src/plugins/messageStorage/sqlite.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/messageStorage/sqlite.js b/src/plugins/messageStorage/sqlite.js index 7fa0b6c2..da26e3b0 100644 --- a/src/plugins/messageStorage/sqlite.js +++ b/src/plugins/messageStorage/sqlite.js @@ -183,18 +183,16 @@ class MessageStorage { } resolve( - rows - .map((row) => { - const msg = JSON.parse(row.msg); - msg.time = row.time; - msg.type = row.type; + rows.reverse().map((row) => { + const msg = JSON.parse(row.msg); + msg.time = row.time; + msg.type = row.type; - const newMsg = new Msg(msg); - newMsg.id = this.client.idMsg++; + const newMsg = new Msg(msg); + newMsg.id = this.client.idMsg++; - return newMsg; - }) - .reverse() + return newMsg; + }) ); } )