From 7ca9941982a7d7a4c126d215770ce71ad2f7f427 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 2 May 2026 11:11:53 +0900 Subject: feat(client): read decks/cards/study from IndexedDB first Switch deckAtom, cardsByDeckAtomFamily, noteTypesAtom, and studyDataAtom to a stale-while-revalidate pattern: read from IndexedDB synchronously, trigger sync in the background, and refetch on sync_complete. When local is empty, await a single bootstrap pull before deciding there's no data. Add study-builder to assemble StudyCards from LocalCard + Note + NoteType + field values, replacing the server /study endpoint dependency. The study session can now run end-to-end offline. Disable submit on all write modals when offline since writes still require the server. Add a "Showing cached data" hint to the sync status indicator. Drop cacheStudyCards (cards arrive via regular sync pull now) and update page tests to reflect that lists no longer refresh by hitting the GET API. --- src/client/components/EditNoteTypeModal.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/client/components/EditNoteTypeModal.tsx') diff --git a/src/client/components/EditNoteTypeModal.tsx b/src/client/components/EditNoteTypeModal.tsx index 27ef5d8..5916ff0 100644 --- a/src/client/components/EditNoteTypeModal.tsx +++ b/src/client/components/EditNoteTypeModal.tsx @@ -1,5 +1,7 @@ +import { useAtomValue } from "jotai"; import { type FormEvent, useEffect, useState } from "react"; import { ApiClientError, apiClient } from "../api"; +import { isOnlineAtom } from "../atoms"; interface NoteType { id: string; @@ -28,6 +30,7 @@ export function EditNoteTypeModal({ const [isReversible, setIsReversible] = useState(false); const [error, setError] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); + const isOnline = useAtomValue(isOnlineAtom); // Sync form state when noteType changes useEffect(() => { @@ -208,7 +211,8 @@ export function EditNoteTypeModal({