Fix JS pass by copy/reference issue.

This commit is contained in:
Bauke 2022-10-25 12:55:07 +02:00
parent e591db7bcf
commit f6571b895b
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 6 additions and 5 deletions

View File

@ -69,20 +69,21 @@ 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();
}
await this.save();
}
public newQueueItemId(): number {