From ce6c0da0e2bfcdd04e731272e577ad1359531119 Mon Sep 17 00:00:00 2001 From: Dragory Date: Sun, 18 Feb 2018 21:09:52 +0200 Subject: [PATCH] Fix sorting in !logs --- src/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index f6c94b1..576b0a2 100644 --- a/src/main.js +++ b/src/main.js @@ -203,7 +203,13 @@ addInboxServerCommand('unblock', (msg, args, thread) => { addInboxServerCommand('logs', (msg, args, thread) => { async function getLogs(userId) { const userThreads = await threads.getClosedThreadsByUserId(userId); - userThreads.reverse(); + + // Descending by date + userThreads.sort((a, b) => { + if (a.created_at > b.created_at) return -1; + if (a.created_at < b.created_at) return 1; + return 0; + }); const threadLines = await Promise.all(userThreads.map(async thread => { const logUrl = await thread.getLogUrl();