atmosphere explorer pds.ls
tool typescript atproto

Better random on home page #22

merged opened by olaren.dev targeting main from olaren.dev/pdsls: better-random
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:6if5m2yo6kroprmmency3gt5/sh.tangled.repo.pull/3me7zgqt65222
+8 -1
Diff #0
+8 -1
src/views/home.tsx
··· 64 64 { did: "did:plc:vafqb3yhndyawabm2t2zhw5z", handle: "neko.moe.observer" }, 65 65 ]; 66 66 67 - const profiles = [...allExampleProfiles].sort(() => Math.random() - 0.5).slice(0, 3); 67 + for (let i = allExampleProfiles.length - 1; i > 0; i--) { 68 + const j = Math.floor(Math.random() * (i + 1)); 69 + [allExampleProfiles[i], allExampleProfiles[j]] = [ 70 + allExampleProfiles[j], 71 + allExampleProfiles[i], 72 + ]; 73 + } 74 + const profiles = allExampleProfiles.slice(0, 3); 68 75 69 76 return ( 70 77 <div class="flex w-full flex-col gap-5 px-2 wrap-break-word">

History

1 round 0 comments
sign up or login to add to the discussion
olaren.dev submitted #0
1 commit
expand
feat: better front page random
expand 0 comments
pull request successfully merged