From bd0e37e0b819bba1248914c03c6a6e17d458e263 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 19 Mar 2022 11:04:20 -0400 Subject: [PATCH] Fix lint issue --- src/commands/move.ts | 4 ++-- src/inversify.config.ts | 2 +- src/services/player.ts | 18 ++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/commands/move.ts b/src/commands/move.ts index 91a3957..731e0da 100644 --- a/src/commands/move.ts +++ b/src/commands/move.ts @@ -19,7 +19,7 @@ export default class implements Command { option.setName('to') .setDescription('position to move the song to') .setRequired(true)); - + private readonly playerManager: PlayerManager; constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) { @@ -37,7 +37,7 @@ export default class implements Command { } if (to < 1) { - throw new Error('position must be at least 1') + throw new Error('position must be at least 1'); } player.move(from, to); diff --git a/src/inversify.config.ts b/src/inversify.config.ts index 5574bb0..2119b98 100644 --- a/src/inversify.config.ts +++ b/src/inversify.config.ts @@ -21,7 +21,7 @@ import Config from './commands/config.js'; import Disconnect from './commands/disconnect.js'; import Favorites from './commands/favorites.js'; import ForwardSeek from './commands/fseek.js'; -import Move from './commands/move.js' +import Move from './commands/move.js'; import NowPlaying from './commands/now-playing.js'; import Pause from './commands/pause.js'; import Play from './commands/play.js'; diff --git a/src/services/player.ts b/src/services/player.ts index 5c38cdd..bb8180d 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -379,6 +379,14 @@ export default class { this.queue = []; } + move(from: number, to: number): void { + if (from > this.queueSize() || to > this.queueSize()) { + throw new Error('Move index is outside the range of the queue.'); + } + + this.queue.splice(this.queuePosition + to, 0, this.queue.splice(this.queuePosition + from, 1)[0]); + } + private getHashForCache(url: string): string { return hasha(url); } @@ -554,14 +562,4 @@ export default class { resolve(returnedStream); }); } - - move(from: number, to: number): void { - - if (from > this.queueSize() || to > this.queueSize()){ - throw new Error('Move index is outside the range of the queue.' ) - } - - this.queue.splice( this.queuePosition + to ,0, this.queue.splice(this.queuePosition + from, 1)[0]); - } - }