From 01cf53c775a8ab9679800d52708c5ef43b3fb723 Mon Sep 17 00:00:00 2001 From: Leonardo Segala Date: Sat, 2 Aug 2025 12:47:16 +0200 Subject: [PATCH] Try to fix thumb up / down --- frontend/src/lib/components/SuggestionList.svelte | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/SuggestionList.svelte b/frontend/src/lib/components/SuggestionList.svelte index 6f5d649..193b33c 100644 --- a/frontend/src/lib/components/SuggestionList.svelte +++ b/frontend/src/lib/components/SuggestionList.svelte @@ -7,9 +7,8 @@ let picked_suggestions: string[] = $state([]) - async function vote(idx: number, amount: number, songId: string) { + async function vote(amount: number, songId: string) { if (picked_suggestions.includes(songId)) return console.log("rejecting vote") - suggestions[idx].upvote += amount await fetch(`/api/song/voting?room=${roomId}&song=${songId}&increment=${amount}`, { method: "POST" }) picked_suggestions.push(songId) console.log("accepted vote") @@ -26,7 +25,7 @@

No suggestions yet! Try to add a new one using the Add button

{/if} - {#each suggestions as sug, idx} + {#each suggestions as sug}
@@ -48,7 +47,8 @@ class={!picked_suggestions.includes(sug.uuid) ? "text-light-pine-green duration-100 hover:scale-150 dark:text-dark-pine-green" : "text-light-pine-muted dark:text-dark-pine-muted"} disabled={!!picked_suggestions.includes(sug.uuid)} onclick={async () => { - await vote(idx, 1, sug.uuid) + sug.upvode += 1 + await vote(1, sug.uuid) }}>

{sug.upvote}

@@ -56,7 +56,8 @@ class={!picked_suggestions.includes(sug.uuid) ? "text-light-pine-red duration-100 hover:scale-150 dark:text-dark-pine-red" : "text-light-pine-muted dark:text-dark-pine-muted"} disabled={!!picked_suggestions.includes(sug.uuid)} onclick={async () => { - await vote(idx, -1, sug.uuid) + sug.upvode += 1 + await vote(-1, sug.uuid) }}>