Skip to content

Commit

Permalink
Fix queue not refreshing after toggling history
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Oct 26, 2024
1 parent 0d0f06e commit d02b889
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next
- Fix queue panel deleting/moving incorrect tracks
- Fix queue not refreshing after toggling history

## 0.19.1 - 2024 Oct 25
- Fix folder playlists not closing
Expand Down
20 changes: 13 additions & 7 deletions src/components/Queue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
queue,
type QueueItem,
} from '../lib/queue'
import { onDestroy } from 'svelte'
import { onDestroy, tick } from 'svelte'
import QueueItemComponent from './QueueItem.svelte'
import { dragged } from '@/lib/drag-drop'
import { get_track } from '@/lib/data'
Expand All @@ -34,8 +34,8 @@
$: first_visible_index = show_history ? 0 : up_next_index
$: autoplay_index = up_next_index + $queue.user_queue.length
let history_list: VirtualListBlock<QueueItem>
let up_next_list: VirtualListBlock<QueueItem>
let history_list: VirtualListBlock<QueueItem> | null
let up_next_list: VirtualListBlock<QueueItem> | null
let autoplay_list: VirtualListBlock<QueueItem>
let visible_qids = [
Expand All @@ -54,16 +54,16 @@
scroll_to: ({ index }) => {
if (show_history) {
if (index < $queue.past.length) {
return history_list.scroll_to_index(index, 40)
return history_list?.scroll_to_index(index, 40)
}
index -= $queue.past.length
if ($queue.current && index === 0) {
return history_list.scroll_to_index(index, 40)
return history_list?.scroll_to_index(index, 40)
}
index -= Number(!!$queue.current)
}
if (index < $queue.user_queue.length) {
return up_next_list.scroll_to_index(index, 40)
return up_next_list?.scroll_to_index(index, 40)
}
index -= $queue.user_queue.length
autoplay_list.scroll_to_index(index, 40)
Expand Down Expand Up @@ -202,7 +202,13 @@
<div class="relative">
<div class="sticky top-0 z-1 flex flex h-[40px] items-center bg-black/50 backdrop-blur-md">
<button
on:click={() => (show_history = !show_history)}
on:click={() => {
show_history = !show_history
tick().then(() => {
up_next_list?.refresh()
autoplay_list.refresh()
})
}}
class="group ml-1.5 flex h-full items-center pl-1 font-semibold"
tabindex="-1"
on:mousedown|preventDefault
Expand Down

0 comments on commit d02b889

Please sign in to comment.