feat: restore the last queue per server
This commit is contained in:
18 files changed
+237
-3
No files matched your search
@@ -61,6 +61,7 @@ const status = {
|
||||
},
|
||||
],
|
||||
default_plays: 5,
|
||||
saved_queue_available: true,
|
||||
}
|
||||
|
||||
const calls = []
|
||||
@@ -129,6 +130,7 @@ check('pozycje list', app.querySelectorAll('.queue-item').length === 4)
|
||||
check('podświetlona aktywna pozycja', app.querySelectorAll('.playing-item').length === 1)
|
||||
check('animacja winylu przy odtwarzaniu', app.querySelector('.vinyl-record.playing') !== null)
|
||||
check('pobrano listę plików na starcie', hasCall('GET /api/uploads'))
|
||||
check('przycisk przywracania kolejki', text().includes('Przywróć ostatnią kolejkę'))
|
||||
|
||||
// --- Interakcje: kliknięcie ma trafić w konkretny endpoint ---------------
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ export const api = {
|
||||
jump: (index: number) => post('/api/jump', { index }),
|
||||
remove: (id: string) => post('/api/remove', { id }),
|
||||
reorder: (queueIds: string[]) => post('/api/reorder', { queue_ids: queueIds }),
|
||||
restoreQueue: () => post('/api/queue/restore'),
|
||||
setTrackPlays: (id: string, plays: number) => post('/api/queue/plays', { id, plays }),
|
||||
setDefaultPlays: (plays: number) => post('/api/default_plays', { default_plays: plays }),
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { Disc, ListMusic } from 'lucide-vue-next'
|
||||
import { Disc, ListMusic, RotateCcw } from 'lucide-vue-next'
|
||||
import QueueItem from '@/components/QueueItem.vue'
|
||||
import { api } from '@/api/client'
|
||||
import { useBotStatus } from '@/composables/useBotStatus'
|
||||
@@ -15,6 +15,7 @@ const { paused } = useBotStatus()
|
||||
|
||||
const queue = computed(() => props.status?.queue ?? [])
|
||||
const queueIndex = computed(() => props.status?.queue_index ?? -1)
|
||||
const savedQueueAvailable = computed(() => props.status?.saved_queue_available ?? false)
|
||||
|
||||
const draggedId = ref<string | null>(null)
|
||||
const dropTargetId = ref<string | null>(null)
|
||||
@@ -73,6 +74,13 @@ const setPlays = (id: string, plays: number) =>
|
||||
run(() => api.setTrackPlays(id, plays), '', 'Błąd aktualizacji odtworzeń')
|
||||
|
||||
const warnInvalidPlays = () => notify('Wartość musi być z przedziału 1-999', 'error')
|
||||
|
||||
const restoreQueue = () =>
|
||||
run(
|
||||
() => api.restoreQueue(),
|
||||
'Przywrócono ostatnią kolejkę',
|
||||
'Nie udało się przywrócić ostatniej kolejki',
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -83,6 +91,14 @@ const warnInvalidPlays = () => notify('Wartość musi być z przedziału 1-999',
|
||||
</h2>
|
||||
<span class="queue-count">{{ tracksLabel(queue.length) }}</span>
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-secondary btn-block restore-queue-button"
|
||||
:disabled="!savedQueueAvailable"
|
||||
title="Przywróć kolejkę zapisaną przed ostatnim zatrzymaniem lub rozłączeniem"
|
||||
@click="restoreQueue"
|
||||
>
|
||||
<RotateCcw /> Przywróć ostatnią kolejkę
|
||||
</button>
|
||||
|
||||
<div class="queue-list-container">
|
||||
<ul class="queue-list">
|
||||
@@ -118,3 +134,9 @@ const warnInvalidPlays = () => notify('Wartość musi być z przedziału 1-999',
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.restore-queue-button {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -66,6 +66,7 @@ export interface BotStatus {
|
||||
active_text_channel_id: string | null
|
||||
guilds: GuildSettings[]
|
||||
default_plays: number
|
||||
saved_queue_available: boolean
|
||||
}
|
||||
|
||||
export type LoopMode = 'off' | 'playlist' | 'single'
|
||||
|
||||
Reference in new issue
Block a user