From e978aabd15014eb6610207e4ccc80fe4ea997404 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 24 Apr 2020 18:41:39 +1000 Subject: [PATCH] Fix map sorting in select map modal --- src/modals/SelectMapModal.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/modals/SelectMapModal.js b/src/modals/SelectMapModal.js index 5b1e9d8..d1122fc 100644 --- a/src/modals/SelectMapModal.js +++ b/src/modals/SelectMapModal.js @@ -43,10 +43,8 @@ function SelectMapModal({ } async function getDefaultMaps() { const defaultMapsWithIds = []; - // Reverse maps to ensure the blank map is first in the list - const sortedMaps = [...defaultMaps].reverse(); - for (let i = 0; i < sortedMaps.length; i++) { - const defaultMap = sortedMaps[i]; + for (let i = 0; i < defaultMaps.length; i++) { + const defaultMap = defaultMaps[i]; const id = `__default-${defaultMap.name}`; defaultMapsWithIds.push({ ...defaultMap, @@ -70,7 +68,7 @@ function SelectMapModal({ let storedMaps = await db.table("maps").toArray(); const defaultMapsWithIds = await getDefaultMaps(); const sortedMaps = [...defaultMapsWithIds, ...storedMaps].sort( - (a, b) => b.timestamp - a.timestamp + (a, b) => a.timestamp - b.timestamp ); setMaps(sortedMaps); }