Fix JS pass by copy/reference issue.
This commit is contained in:
parent
e591db7bcf
commit
f6571b895b
|
@ -69,21 +69,22 @@ export class Settings {
|
|||
}
|
||||
|
||||
const previousIndex = targetItem.sortIndex;
|
||||
let targetIndex = previousIndex;
|
||||
if (direction === 'down') {
|
||||
targetItem.sortIndex += 1;
|
||||
targetIndex += 1;
|
||||
} else if (direction === 'up') {
|
||||
targetItem.sortIndex -= 1;
|
||||
targetIndex -= 1;
|
||||
}
|
||||
|
||||
const existingItem = this.queue.find(
|
||||
(item) => item.sortIndex === targetItem.sortIndex,
|
||||
(item) => item.sortIndex === targetIndex,
|
||||
);
|
||||
if (existingItem !== undefined) {
|
||||
existingItem.sortIndex = previousIndex;
|
||||
}
|
||||
|
||||
targetItem.sortIndex = targetIndex;
|
||||
await this.save();
|
||||
}
|
||||
}
|
||||
|
||||
public newQueueItemId(): number {
|
||||
const item = this.queue.sort((a, b) => b.id - a.id)[0];
|
||||
|
|
Loading…
Reference in New Issue