merge: websockets & refactoring

This commit is contained in:
Mat12143 2025-08-02 03:56:01 +02:00
commit 7020a334a2
8 changed files with 218 additions and 26 deletions

View file

@ -7,6 +7,7 @@
import SuggestionList from "$lib/components/SuggestionList.svelte"
import { getQueueSongs, getSuggestions, joinRoom } from "$lib/utils.js"
import type { FetchError } from "$lib/types.js"
import { io } from "socket.io-client"
let { data } = $props()
@ -29,10 +30,11 @@
}
;[returnError, sugg] = await getSuggestions(data.roomId)
if (returnError) {
return
}
if (returnError) return
// Setup websocket connection
let socket = io("/", { path: "/ws" })
await socket.emitWithAck("join_room", { id: data.roomId })
;[returnError, queue, index] = await getQueueSongs(data.roomId)
if (returnError) {
return

View file

@ -1,5 +1,7 @@
import { error, type Load, type ServerLoad } from "@sveltejs/kit"
import type { PageLoad } from "./$types"
import type { FetchError } from "$lib/util"
import { parseSuggestion, type Suggestion } from "$lib/types"
export const load: PageLoad = async ({ params }) => {
if (params.id) {