From be2a9f3a3e587c2849edc9ebd52e9320f3155765 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 8 Sep 2026 12:50:34 +0200 Subject: [PATCH] fix: crash, design for playlists crash was caused by indices not updating correctly --- .../components/main/PlaylistsComponent.vue | 9 ++- .../components/main/SmallPlayerComponent.vue | 2 +- .../components/playlists/UserPlaylists.vue | 53 ++++++++++-------- web/src/scss/components/playlists.scss | 55 +++++++++++++++++++ web/src/scss/components/sortablelist.scss | 1 + web/src/ts/shared/index.ts | 7 ++- web/src/views/SharedView.vue | 4 +- 7 files changed, 104 insertions(+), 27 deletions(-) create mode 100644 web/src/scss/components/playlists.scss diff --git a/web/src/components/main/PlaylistsComponent.vue b/web/src/components/main/PlaylistsComponent.vue index c803b39..bdb8e40 100644 --- a/web/src/components/main/PlaylistsComponent.vue +++ b/web/src/components/main/PlaylistsComponent.vue @@ -4,8 +4,15 @@ + + diff --git a/web/src/components/main/SmallPlayerComponent.vue b/web/src/components/main/SmallPlayerComponent.vue index 1d58526..948d637 100644 --- a/web/src/components/main/SmallPlayerComponent.vue +++ b/web/src/components/main/SmallPlayerComponent.vue @@ -28,7 +28,7 @@ }; const song: ComputedRef = computed( () => { - if ( queueIdx.value >= 0 ) { + if ( queueIdx.value >= 0 && queue.value.length > queueIdx.value ) { return queue.value[ queueIdx.value ]!; } else { return { diff --git a/web/src/components/playlists/UserPlaylists.vue b/web/src/components/playlists/UserPlaylists.vue index 42eb691..729e980 100644 --- a/web/src/components/playlists/UserPlaylists.vue +++ b/web/src/components/playlists/UserPlaylists.vue @@ -69,37 +69,46 @@ + + diff --git a/web/src/scss/components/playlists.scss b/web/src/scss/components/playlists.scss new file mode 100644 index 0000000..8c03bfa --- /dev/null +++ b/web/src/scss/components/playlists.scss @@ -0,0 +1,55 @@ +.playlists { + height: 100%; + width: 100%; + position: relative; + + >.playlist-wrapper { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + + >.playlist-container { + width: 100%; + height: 100%; + display: flex; + align-items: center; + flex-direction: column; + overflow-x: scroll; + + >.playlist { + width: 50%; + display: flex; + justify-content: center; + align-items: center; + padding: 10px; + height: 3rem; + + >h2, >input { + margin: 0; + margin-right: auto; + margin-left: 10px; + width: 100%; + text-align: start; + cursor: pointer; + } + >input { + margin-right: auto; + margin-left: 10px; + width: 50%; + min-width: 200px; + } + + >.fa-circle-play { + font-size: 1.5rem; + } + + >.fa-solid { + cursor: pointer; + } + } + } + } +} diff --git a/web/src/scss/components/sortablelist.scss b/web/src/scss/components/sortablelist.scss index 9f82471..459a286 100644 --- a/web/src/scss/components/sortablelist.scss +++ b/web/src/scss/components/sortablelist.scss @@ -23,6 +23,7 @@ &.moving { position: fixed; + user-select: none; } >i { diff --git a/web/src/ts/shared/index.ts b/web/src/ts/shared/index.ts index 8daa20c..76a6188 100644 --- a/web/src/ts/shared/index.ts +++ b/web/src/ts/shared/index.ts @@ -43,7 +43,12 @@ const connect = (): Promise => { currentQueueIdx.value = data.state.index; isPlaying.value = data.state.playing; startTime.value = data.state.start; - playbackTime.value = data.state.offset; + + if ( data.playlist.length === 0 ) + playbackTime.value = 0; + else + playbackTime.value = data.state.offset; + playbackOffset.value = data.state.offset; playbackProgress.value = data.state.offset / ( data.playlist[ data.state.index ]?.duration ?? -1 ); resolve(); diff --git a/web/src/views/SharedView.vue b/web/src/views/SharedView.vue index 7e4c32e..dc6a380 100644 --- a/web/src/views/SharedView.vue +++ b/web/src/views/SharedView.vue @@ -44,7 +44,7 @@ }, 250 ); } ); const song: ComputedRef = computed( () => { - if ( currentQueueIdx.value >= 0 ) + if ( currentQueueIdx.value >= 0 && currentQueue.value.length > currentQueueIdx.value ) return currentQueue.value[currentQueueIdx.value]!; else return { @@ -68,7 +68,7 @@

- {{ beautifyTime( playbackTime ) }} + {{ beautifyTime( song.duration >= 0 ? playbackTime : -1 ) }}

{{ beautifyTime( song.duration ) }}