perf: preload and cache countdowns
ci / docker (push) Successful in 3m49s

This commit is contained in:
2026-09-07 17:50:26 +08:00
parent 635930db50
commit a02b6f660c
6 changed files with 64 additions and 5 deletions
+9
View File
@@ -115,6 +115,7 @@ export function isFabDrag(deltaX: number, deltaY: number, threshold = 8) {
}
let habitGridCache: { week: string; habits: unknown[] } | null = null
let countdownCache: { items: unknown[]; archived: unknown[] } | null = null
export function readHabitGridCache<T>(week: string): T[] | null {
return habitGridCache?.week === week ? habitGridCache.habits as T[] : null
@@ -124,6 +125,14 @@ export function writeHabitGridCache<T>(week: string, habits: T[]) {
habitGridCache = { week, habits }
}
export function readCountdownCache<T>() {
return countdownCache as { items: T[]; archived: T[] } | null
}
export function writeCountdownCache<T>(items: T[], archived: T[]) {
countdownCache = { items, archived }
}
export function formatApiErrorDetail(detail: unknown): string {
if (typeof detail === 'string') return detail
if (Array.isArray(detail)) {