From f6571b895b8dd058f3d3c397babf460c6d1ce792 Mon Sep 17 00:00:00 2001 From: Bauke Date: Tue, 25 Oct 2022 12:55:07 +0200 Subject: [PATCH] Fix JS pass by copy/reference issue. --- source/settings/settings.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 {