Add default room for testing && show error msg
This commit is contained in:
parent
436553809a
commit
f7351aecf8
2 changed files with 15 additions and 4 deletions
|
@ -29,9 +29,9 @@ init_db(state.db)
|
|||
state.rooms[1000] = Room(
|
||||
id=1000,
|
||||
coord=Coordinates(46.6769043, 11.1851585),
|
||||
name="Test Room",
|
||||
pin=None,
|
||||
tags=set(),
|
||||
name="Lido Scena",
|
||||
pin=1234,
|
||||
tags=set(["chill", "raggaetton", "spanish", "latino", "mexican", "rock"]),
|
||||
range_size=150,
|
||||
songs={},
|
||||
history=[],
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
let input = $state("")
|
||||
let loading: boolean = $state(false)
|
||||
let cooldowned: boolean = $state(false)
|
||||
let errorMsg: string = $state()
|
||||
|
||||
$effect(() => {
|
||||
console.log("cooldowned is now", cooldowned)
|
||||
|
@ -14,10 +15,15 @@
|
|||
|
||||
async function sendSong() {
|
||||
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 = ""
|
||||
loading = false
|
||||
|
||||
if (!json.success) {
|
||||
errorMsg = json.error
|
||||
}
|
||||
|
||||
cooldowned = true
|
||||
setTimeout(() => {
|
||||
cooldowned = false
|
||||
|
@ -35,6 +41,7 @@
|
|||
class="h-[50px] w-3/4 rounded px-4 font-bold text-white outline-none"
|
||||
bind:value={input}
|
||||
onkeydown={(e) => {
|
||||
errorMsg = null
|
||||
if (e.key == "Enter") {
|
||||
sendSong()
|
||||
}
|
||||
|
@ -56,3 +63,7 @@
|
|||
>
|
||||
<span class="i-lucide-chevrons-left"></span>
|
||||
</div>
|
||||
|
||||
<p class="text-red-500 font-semibold">
|
||||
{errorMsg}
|
||||
</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue