diff --git a/source/settings/settings.ts b/source/settings/settings.ts index c6e1769..a60ff42 100644 --- a/source/settings/settings.ts +++ b/source/settings/settings.ts @@ -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 {