Fix wish ordering

pull/1/head
I Made Setia Baruna 2021-03-08 23:35:24 +08:00
parent 4bc8cdd68a
commit 781ec913f2
2 changed files with 11 additions and 5 deletions

View File

@ -347,10 +347,7 @@
const importedWishes = wishes[code].slice().reverse();
const oldestWish = importedWishes[0];
localWishes = localWishes
.slice()
.filter((e) => e.time < oldestWish.time)
.sort((a, b) => a.time - b.time);
localWishes = localWishes.slice().filter((e) => e.time < oldestWish.time);
const combined = [...localWishes, ...importedWishes];

View File

@ -99,7 +99,16 @@
}
function addPullDetail(newPull) {
pulls = [...pulls, newPull];
let index = -1;
for (let i = pulls.length - 1; i >= 0; i--) {
if (newPull.time >= pulls[i].time) {
index = i + 1;
break;
}
}
const lastPulls = [...pulls];
lastPulls.splice(index, 0, newPull);
pulls = lastPulls;
closeModal();
saveData();
}