Use noteContextReorder event instead

This commit is contained in:
dymani
2023-05-31 01:53:55 +08:00
parent 2a39906993
commit 735852b3c1
4 changed files with 46 additions and 23 deletions

View File

@@ -451,16 +451,15 @@ export default class TabManager extends Component {
this.tabsUpdate.scheduleUpdate();
}
noteContextReorderEvent({ntxIdsInOrder}) {
const order = {};
let i = 0;
for (const ntxId of ntxIdsInOrder) {
order[ntxId] = i++;
}
noteContextReorderEvent({ntxIdsInOrder, mainNtxIdsInOrder}) {
const order = Object.fromEntries(ntxIdsInOrder.map((v, i) => [v, i]));
this.children.sort((a, b) => order[a.ntxId] < order[b.ntxId] ? -1 : 1);
if (!!mainNtxIdsInOrder && mainNtxIdsInOrder.length === this.children.length) {
this.children.forEach((c, i) => c.mainNtxId = mainNtxIdsInOrder[i]);
}
this.tabsUpdate.scheduleUpdate();
}