diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-08 21:18:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-08 21:18:55 +0900 |
| commit | 5e7c3ad7ed8c287b538de97d4de3a4df87e9a100 (patch) | |
| tree | a3b400fb00ba9544d51640cb5d6eb494c2b095f3 /src/client/atoms/study.ts | |
| parent | e17c87441d9beff9c1241cbe3ba71c402a7c0c3f (diff) | |
| download | kioku-5e7c3ad7ed8c287b538de97d4de3a4df87e9a100.tar.gz kioku-5e7c3ad7ed8c287b538de97d4de3a4df87e9a100.tar.zst kioku-5e7c3ad7ed8c287b538de97d4de3a4df87e9a100.zip | |
feat(study): use seeded PRNG for deterministic card shuffle order
Shuffle order is now fixed within a study day by seeding mulberry32
with the study day boundary timestamp (3:00 AM rollover).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/client/atoms/study.ts')
| -rw-r--r-- | src/client/atoms/study.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/client/atoms/study.ts b/src/client/atoms/study.ts index 324f92e..fca17b7 100644 --- a/src/client/atoms/study.ts +++ b/src/client/atoms/study.ts @@ -1,7 +1,8 @@ import { atomFamily } from "jotai-family"; import { atomWithSuspenseQuery } from "jotai-tanstack-query"; +import { getStartOfStudyDayBoundary } from "../../shared/date"; import { apiClient } from "../api/client"; -import { shuffle } from "../utils/shuffle"; +import { createSeededRandom, shuffle } from "../utils/random"; export interface StudyCard { id: string; @@ -54,9 +55,10 @@ export const studyDataAtomFamily = atomFamily((deckId: string) => cards: StudyCard[]; }>(cardsRes); + const seed = getStartOfStudyDayBoundary().getTime(); return { deck: deckData.deck, - cards: shuffle(cardsData.cards), + cards: shuffle(cardsData.cards, createSeededRandom(seed)), }; }, })), |
