From 597f6ac1878cbd2090f5be21ce14c7136efae69f Mon Sep 17 00:00:00 2001 From: smuddyx Date: Sun, 22 Mar 2020 00:08:09 +0100 Subject: [PATCH] fix: ordering songs in show --- src/app/modules/shows/show/show.component.html | 4 ++-- src/app/modules/shows/show/show.component.ts | 5 ++--- src/app/modules/shows/show/song/song.component.ts | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/modules/shows/show/show.component.html b/src/app/modules/shows/show/show.component.html index d245437..92a7043 100644 --- a/src/app/modules/shows/show/show.component.html +++ b/src/app/modules/shows/show/show.component.html @@ -2,12 +2,12 @@ -
+
diff --git a/src/app/modules/shows/show/show.component.ts b/src/app/modules/shows/show/show.component.ts index 436c247..5b31b1c 100644 --- a/src/app/modules/shows/show/show.component.ts +++ b/src/app/modules/shows/show/show.component.ts @@ -64,9 +64,8 @@ export class ShowComponent implements OnInit { event.source.value = null; } - public getSong(songs: Song[], songId: string): Song { - if (!songs) return null; - const filtered = songs.filter(_ => _.id === songId); + public getSong(songId: string): Song { + const filtered = this.songs.filter(_ => _.id === songId); return filtered.length > 0 ? filtered[0] : null; } } diff --git a/src/app/modules/shows/show/song/song.component.ts b/src/app/modules/shows/show/song/song.component.ts index 02ff304..dc66c2c 100644 --- a/src/app/modules/shows/show/song/song.component.ts +++ b/src/app/modules/shows/show/song/song.component.ts @@ -54,7 +54,7 @@ export class SongComponent implements OnInit { } public async reorderUp(): Promise { - const index = this.showSongs.findIndex(_ => _.songId === this.song.id); + const index = this.showSongs.findIndex(_ => _.songId === this._song.id); if (index === 0) return; const song = this.showSongs[index]; @@ -65,7 +65,7 @@ export class SongComponent implements OnInit { } public async reorderDown(): Promise { - const index = this.showSongs.findIndex(_ => _.songId === this.song.id); + const index = this.showSongs.findIndex(_ => _.songId === this._song.id); if (index === this.showSongs.length - 1) return; const song = this.showSongs[index];