feat(queue): add confirmation dialog when clearing the queue

Wraps the clear button in an AlertDialog that shows the number of songs
to be removed, requiring explicit confirmation before clearing.
This commit is contained in:
2026-02-12 21:56:14 -08:00
parent 3944cf6ff4
commit c0ff938bf3

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { GripVertical, Play, X } from "@lucide/svelte";
import * as AlertDialog from "$lib/components/ui/alert-dialog";
import { Button } from "$lib/components/ui/button";
import VirtualList from "$lib/components/ui/VirtualList.svelte";
import { player } from "$lib/player/store.svelte";
@@ -53,15 +54,30 @@
>
{/if}
</h3>
<Button
variant="ghost"
size="sm"
class="h-6 w-6 p-0"
onclick={() => player.clearQueue()}
>
<span class="sr-only">Clear</span>
<X class="h-3 w-3" />
</Button>
<AlertDialog.Root>
<AlertDialog.Trigger>
{#snippet child({ props })}
<Button variant="ghost" size="sm" class="h-6 w-6 p-0" {...props}>
<span class="sr-only">Clear</span>
<X class="h-3 w-3" />
</Button>
{/snippet}
</AlertDialog.Trigger>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Clear queue?</AlertDialog.Title>
<AlertDialog.Description>
This will remove all {player.displayQueue.length} songs from the queue.
</AlertDialog.Description>
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<AlertDialog.Action onclick={() => player.clearQueue()}
>Clear</AlertDialog.Action
>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>
</div>
<VirtualList