merge: websockets & refactoring
This commit is contained in:
commit
7020a334a2
8 changed files with 218 additions and 26 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue