From ddbf307c29325b824a10d3ad6238b00a0e1d1097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Sun, 24 Nov 2019 21:36:15 +0100 Subject: [PATCH] sort table rows by createdAt record property instead of IDs --- lib/public/scripts.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/public/scripts.js b/lib/public/scripts.js index b55e6a8..717815e 100644 --- a/lib/public/scripts.js +++ b/lib/public/scripts.js @@ -174,10 +174,12 @@ storageContents .sort((a, b) => { - if (a.id < b.id) { + const aDate = new Date(a.createdAt) + const bDate = new Date(b.createdAt) + if (aDate < bDate) { return -1 } - if (a.id > b.id) { + if (aDate > bDate) { return 1 } return 0