Fix map sorting in select map modal
This commit is contained in:
parent
ece974c5d9
commit
e978aabd15
@ -43,10 +43,8 @@ function SelectMapModal({
|
|||||||
}
|
}
|
||||||
async function getDefaultMaps() {
|
async function getDefaultMaps() {
|
||||||
const defaultMapsWithIds = [];
|
const defaultMapsWithIds = [];
|
||||||
// Reverse maps to ensure the blank map is first in the list
|
for (let i = 0; i < defaultMaps.length; i++) {
|
||||||
const sortedMaps = [...defaultMaps].reverse();
|
const defaultMap = defaultMaps[i];
|
||||||
for (let i = 0; i < sortedMaps.length; i++) {
|
|
||||||
const defaultMap = sortedMaps[i];
|
|
||||||
const id = `__default-${defaultMap.name}`;
|
const id = `__default-${defaultMap.name}`;
|
||||||
defaultMapsWithIds.push({
|
defaultMapsWithIds.push({
|
||||||
...defaultMap,
|
...defaultMap,
|
||||||
@ -70,7 +68,7 @@ function SelectMapModal({
|
|||||||
let storedMaps = await db.table("maps").toArray();
|
let storedMaps = await db.table("maps").toArray();
|
||||||
const defaultMapsWithIds = await getDefaultMaps();
|
const defaultMapsWithIds = await getDefaultMaps();
|
||||||
const sortedMaps = [...defaultMapsWithIds, ...storedMaps].sort(
|
const sortedMaps = [...defaultMapsWithIds, ...storedMaps].sort(
|
||||||
(a, b) => b.timestamp - a.timestamp
|
(a, b) => a.timestamp - b.timestamp
|
||||||
);
|
);
|
||||||
setMaps(sortedMaps);
|
setMaps(sortedMaps);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user