This commit is contained in:
Simone Tesini 2025-08-02 13:45:32 +02:00
commit 7443d600e7
2 changed files with 15 additions and 4 deletions

View file

@ -29,9 +29,9 @@ init_db(state.db)
state.rooms[1000] = Room( state.rooms[1000] = Room(
id=1000, id=1000,
coord=Coordinates(46.6769043, 11.1851585), coord=Coordinates(46.6769043, 11.1851585),
name="Test Room", name="Lido Scena",
pin=None, pin=1234,
tags=set(), tags=set(["chill", "raggaetton", "spanish", "latino", "mexican", "rock"]),
range_size=150, range_size=150,
songs={}, songs={},
history=[], history=[],

View file

@ -7,6 +7,7 @@
let input = $state("") let input = $state("")
let loading: boolean = $state(false) let loading: boolean = $state(false)
let cooldowned: boolean = $state(false) let cooldowned: boolean = $state(false)
let errorMsg: string = $state()
$effect(() => { $effect(() => {
console.log("cooldowned is now", cooldowned) console.log("cooldowned is now", cooldowned)
@ -14,10 +15,15 @@
async function sendSong() { async function sendSong() {
loading = true loading = true
await fetch(`/api/addsong?room=${roomId}&query=${input}`, { method: "POST" }) const res = await fetch(`/api/addsong?room=${roomId}&query=${input}`, { method: "POST" })
const json = await res.json()
input = "" input = ""
loading = false loading = false
if (!json.success) {
errorMsg = json.error
}
cooldowned = true cooldowned = true
setTimeout(() => { setTimeout(() => {
cooldowned = false cooldowned = false
@ -35,6 +41,7 @@
class="h-[50px] w-3/4 rounded px-4 font-bold text-white outline-none" class="h-[50px] w-3/4 rounded px-4 font-bold text-white outline-none"
bind:value={input} bind:value={input}
onkeydown={(e) => { onkeydown={(e) => {
errorMsg = null
if (e.key == "Enter") { if (e.key == "Enter") {
sendSong() sendSong()
} }
@ -56,3 +63,7 @@
> >
<span class="i-lucide-chevrons-left"></span> <span class="i-lucide-chevrons-left"></span>
</div> </div>
<p class="text-red-500 font-semibold">
{errorMsg}
</p>