Skip to content

Commit

Permalink
fix: prevent bug with members shuffling (#218)
Browse files Browse the repository at this point in the history
* Fix issue with members displaying twice

* Swap with true shuffle method
  • Loading branch information
KTibow committed Jan 10, 2024
1 parent db2bde3 commit 66bb4b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/donate/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
console.error('Failed to copy crypto wallet:', error);
}
}
const shuffle = (array: unknown[]) =>
array
.map((value) => ({ value, sort: Math.random() }))
.sort((a, b) => a.sort - b.sort)
.map(({ value }) => value);
</script>

<Head
Expand Down Expand Up @@ -119,7 +125,7 @@
{#if data.members.length > 0}
<section class="team">
<!-- randomize team members because equality -->
{#each data.members.sort(() => (Math.random() > 0.5 ? -1 : 1)) as member, i}
{#each shuffle(data.members) as member, i}
<TeamMember {member} {i} />
{/each}
</section>
Expand Down

0 comments on commit 66bb4b1

Please sign in to comment.