diff --git a/src/lib/feature/post/media/PostPoll.svelte b/src/lib/feature/post/media/PostPoll.svelte index 37790b86..cb391146 100644 --- a/src/lib/feature/post/media/PostPoll.svelte +++ b/src/lib/feature/post/media/PostPoll.svelte @@ -33,12 +33,15 @@ (post.poll.my_votes?.length ?? 0) > 0 ), ) - let chosen = $state(canVote ? undefined : -1) + let chosen = $state(canVote ? undefined : -1) let options = $derived( post.poll.choices.map((i) => ({ ...i, - num_votes: chosen == i.id ? i.num_votes + 1 : i.num_votes, + num_votes: + (typeof chosen !== 'number' && chosen?.includes(i.id)) || chosen == i.id + ? i.num_votes + 1 + : i.num_votes, })), ) let totalVotes = $derived(options.reduce((a, b) => a + b.num_votes, 0)) @@ -52,7 +55,7 @@ loading = true - if (typeof id !== 'number') chosen = id[0] + if (typeof id !== 'number') chosen = id else chosen = id canVote = false @@ -82,7 +85,13 @@ } -
castVote(selected!)}> + { + e.preventDefault() + castVote(selected!) + }} +> {#each options.toSorted((a, b) => a.sort_order - b.sort_order) as choice} {@const active =