From 76f63057bc22deda2c36960254a01b7edf140271 Mon Sep 17 00:00:00 2001 From: Marcin Macierzanka Date: Sun, 13 Sep 2026 16:04:35 +0200 Subject: [PATCH] refactor: remove success notifications from api action wrappers and websocket connection --- frontend/src/components/AddTrackPanel.vue | 2 +- frontend/src/components/HistoryPanel.vue | 2 +- frontend/src/components/PlayerPanel.vue | 22 ++++++------------- frontend/src/components/QueuePanel.vue | 6 ++--- frontend/src/components/VoiceChannelPanel.vue | 4 ++-- frontend/src/composables/useBotStatus.ts | 9 -------- frontend/src/composables/useUploads.ts | 2 +- 7 files changed, 15 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/AddTrackPanel.vue b/frontend/src/components/AddTrackPanel.vue index cfbdc02..288b985 100644 --- a/frontend/src/components/AddTrackPanel.vue +++ b/frontend/src/components/AddTrackPanel.vue @@ -25,7 +25,7 @@ async function submit() { busy.value = true const guildId = props.status.active_voice_channel.guild_id const pendingId = addPendingTrack(guildId, trimmed) - const added = await run(() => api.play(trimmed), 'Dodano utwór do kolejki!', 'Błąd dodawania') + const added = await run(() => api.play(trimmed), '', 'Błąd dodawania') removePendingTrack(pendingId) if (added) query.value = '' busy.value = false diff --git a/frontend/src/components/HistoryPanel.vue b/frontend/src/components/HistoryPanel.vue index a2ba640..104e5c6 100644 --- a/frontend/src/components/HistoryPanel.vue +++ b/frontend/src/components/HistoryPanel.vue @@ -34,7 +34,7 @@ async function replay(entry: HistoryTrack) { notify('Ten wpis historii nie ma źródła do odtworzenia', 'error') return } - await run(() => api.play(entry.url as string), 'Dodano z historii do kolejki!', 'Błąd') + await run(() => api.play(entry.url as string), '', 'Błąd') } finally { removePendingTrack(pendingId) } diff --git a/frontend/src/components/PlayerPanel.vue b/frontend/src/components/PlayerPanel.vue index 201f7af..240c54c 100644 --- a/frontend/src/components/PlayerPanel.vue +++ b/frontend/src/components/PlayerPanel.vue @@ -114,7 +114,7 @@ async function onToggleEffect(fx: PlayerEffect) { const next = !fx.active await run( () => api.toggleEffect(fx.id, next), - next ? `Włączono efekt: ${fx.name} ✨` : `Wyłączono efekt: ${fx.name}`, + '', `Błąd przełączania efektu ${fx.name}`, ) } @@ -127,7 +127,7 @@ async function togglePlayback() { } await run( () => (playing.value ? api.pause() : api.resume()), - playing.value ? 'Wstrzymano odtwarzanie' : 'Wznowiono odtwarzanie', + '', 'Błąd sterowania odtwarzaniem', ) } @@ -158,7 +158,7 @@ async function commitSeek() { const position = seekPosition.value seekSubmitting.value = true try { - await run(() => api.seek(position), 'Przewinięto utwór', 'Błąd przewijania utworu') + await run(() => api.seek(position), '', 'Błąd przewijania utworu') } finally { seekSubmitting.value = false seeking.value = false @@ -170,28 +170,20 @@ async function restartCurrent() { seekPosition.value = 0 seekSubmitting.value = true try { - await run(() => api.seek(0), 'Uruchomiono utwór od początku', 'Błąd uruchamiania od początku') + await run(() => api.seek(0), '', 'Błąd uruchamiania od początku') } finally { seekSubmitting.value = false seeking.value = false } } -const skip = () => run(() => api.skip(), 'Pominięto utwór', 'Błąd pomijania utworu') +const skip = () => run(() => api.skip(), '', 'Błąd pomijania utworu') -const stop = () => - run(() => api.stop(), 'Zatrzymano odtwarzanie i wyczyszczono kolejkę', 'Błąd zatrzymywania') - -const LOOP_MESSAGES = { - playlist: 'Zapętlanie kolejki włączone', - single: 'Zapętlanie utworu włączone', - off: 'Zapętlanie wyłączone', -} as const +const stop = () => run(() => api.stop(), '', 'Błąd zatrzymywania') async function cycleLoop() { try { - const { mode } = await api.cycleLoop() - notify(LOOP_MESSAGES[mode], 'info') + await api.cycleLoop() } catch { notify('Błąd ustawiania pętli', 'error') } diff --git a/frontend/src/components/QueuePanel.vue b/frontend/src/components/QueuePanel.vue index 482e150..5266a4c 100644 --- a/frontend/src/components/QueuePanel.vue +++ b/frontend/src/components/QueuePanel.vue @@ -25,7 +25,7 @@ const draggedId = ref(null) const dropTargetId = ref(null) const sendOrder = (ids: string[]) => - run(() => api.reorder(ids), 'Zmieniono kolejność utworów!', 'Nie udało się zapisać kolejności') + run(() => api.reorder(ids), '', 'Nie udało się zapisać kolejności') function reordered(from: number, to: number): string[] { const ids = queue.value.map((track) => track.id) @@ -69,10 +69,10 @@ function moveDown(index: number) { } const jump = (index: number) => - run(() => api.jump(index), 'Zmieniono odtwarzany utwór', 'Nie udało się zmienić utworu') + run(() => api.jump(index), '', 'Nie udało się zmienić utworu') const remove = (id: string) => - run(() => api.remove(id), 'Usunięto utwór z kolejki', 'Nie udało się usunąć utworu') + run(() => api.remove(id), '', 'Nie udało się usunąć utworu') const setPlays = (id: string, plays: number) => run(() => api.setTrackPlays(id, plays), '', 'Błąd aktualizacji odtworzeń') diff --git a/frontend/src/components/VoiceChannelPanel.vue b/frontend/src/components/VoiceChannelPanel.vue index 3664747..d978869 100644 --- a/frontend/src/components/VoiceChannelPanel.vue +++ b/frontend/src/components/VoiceChannelPanel.vue @@ -52,14 +52,14 @@ watch( async function toggle() { if (active.value) { - await run(() => api.disconnect(), 'Rozłączono z kanału głosowego', 'Błąd rozłączania') + await run(() => api.disconnect(), '', 'Błąd rozłączania') return } if (!selected.value) { notify('Wybierz kanał głosowy z listy!', 'error') return } - await run(() => api.connect(selected.value), 'Połączono z kanałem głosowym!', 'Nie udało się połączyć') + await run(() => api.connect(selected.value), '', 'Nie udało się połączyć') } async function setNotificationChannel() { diff --git a/frontend/src/composables/useBotStatus.ts b/frontend/src/composables/useBotStatus.ts index 4e41d4c..164c60d 100644 --- a/frontend/src/composables/useBotStatus.ts +++ b/frontend/src/composables/useBotStatus.ts @@ -1,6 +1,5 @@ import { onUnmounted, ref } from 'vue' import type { BotStatus } from '@/types/status' -import { useToasts } from '@/composables/useToasts' import { getGuildId, setGuildId } from '@/api/client' const RECONNECT_DELAY_MS = 3000 @@ -13,13 +12,10 @@ const pendingTracks = ref<{ id: string; guildId: string; title: string }[]>([]) let socket: WebSocket | null = null let reconnectTimer: number | null = null -let connectedOnce = false let subscribers = 0 /** Jedno połączenie WebSocket na aplikację, niezależnie od liczby komponentów. */ export function useBotStatus() { - const { notify } = useToasts() - function open() { const scheme = window.location.protocol === 'https:' ? 'wss:' : 'ws:' const guild = getGuildId() @@ -30,11 +26,6 @@ export function useBotStatus() { currentSocket.onopen = () => { connected.value = true - notify( - connectedOnce ? 'Połączenie WebSocket przywrócone (Live)!' : 'WebSocket zsynchronizowany (Live)!', - 'success', - ) - connectedOnce = true } currentSocket.onmessage = (event) => { diff --git a/frontend/src/composables/useUploads.ts b/frontend/src/composables/useUploads.ts index 56116f4..c458b47 100644 --- a/frontend/src/composables/useUploads.ts +++ b/frontend/src/composables/useUploads.ts @@ -40,7 +40,7 @@ export function useUploads() { } async function enqueue(filename: string) { - await run(() => api.playFile(filename), 'Dodano plik do kolejki!', 'Błąd odtwarzania') + await run(() => api.playFile(filename), '', 'Błąd odtwarzania') await refresh() }