diff options
Diffstat (limited to 'src/client/atoms/study.ts')
| -rw-r--r-- | src/client/atoms/study.ts | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/client/atoms/study.ts b/src/client/atoms/study.ts index 73966fd..17519de 100644 --- a/src/client/atoms/study.ts +++ b/src/client/atoms/study.ts @@ -3,21 +3,11 @@ import { atomWithSuspenseQuery } from "jotai-tanstack-query"; import { getStartOfStudyDayBoundary } from "../../shared/date"; import { apiClient } from "../api/client"; import type { CardStateType } from "../db"; +import { cacheStudyCards, type ServerStudyCard } from "../sync"; import { createSeededRandom, shuffle } from "../utils/random"; -export interface StudyCard { - id: string; - deckId: string; - noteId: string; - isReversed: boolean; - front: string; - back: string; +export interface StudyCard extends ServerStudyCard { state: CardStateType; - due: string; - stability: number; - difficulty: number; - reps: number; - lapses: number; noteType: { frontTemplate: string; backTemplate: string; @@ -56,6 +46,9 @@ export const studyDataAtomFamily = atomFamily((deckId: string) => cards: StudyCard[]; }>(cardsRes); + // Cache cards in IndexedDB so reviews can be submitted offline. + await cacheStudyCards(cardsData.cards); + const seed = getStartOfStudyDayBoundary().getTime(); return { deck: deckData.deck, |
