Download src/lib/api/phase3-activity.ts from asnannp/DocDoeAI: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/asnannp/DocDoeAI/resolve/main/src/lib/api/phase3-activity.ts
- Command line
-
hf download hf://spaces/asnannp/DocDoeAI/src/lib/api/phase3-activity.ts
-
curl -L -o phase3-activity.ts https://huggingface.co/spaces/asnannp/DocDoeAI/resolve/main/src/lib/api/phase3-activity.ts
1.11 kB
| import { apiGet, apiPost } from "@/lib/api/client"; | |
| import { hasLiveSession } from "@/lib/api/mode"; | |
| import type { Phase3Activity } from "@/lib/phase3-learning"; | |
| /** | |
| * Backend persistence for the learning-support activity aggregate (PYQ result, | |
| * weak topics, revision saves, recovery actions). localStorage stays the | |
| * offline source of truth; this makes the data survive login / device change. | |
| * Best-effort, no-op when logged out. | |
| */ | |
| type Phase3ActivityRemote = { data: Phase3Activity; updated_at: string }; | |
| export async function savePhase3ActivityRemote(data: Phase3Activity): Promise<boolean> { | |
| if (!hasLiveSession()) return false; | |
| try { | |
| await apiPost<Phase3ActivityRemote, { data: Phase3Activity }>("/phase3-activity", { data }); | |
| return true; | |
| } catch { | |
| return false; | |
| } | |
| } | |
| export async function getPhase3ActivityRemote(): Promise<Phase3Activity | null> { | |
| if (!hasLiveSession()) return null; | |
| try { | |
| const remote = await apiGet<Phase3ActivityRemote | null>( | |
| "/phase3-activity/me?optional=true", | |
| ); | |
| return remote?.data ?? null; | |
| } catch { | |
| return null; | |
| } | |
| } | |