fix: persist completed item visibility
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
type BooleanStorage = Pick<Storage, 'getItem' | 'setItem'>
|
||||
|
||||
export function readStoredBoolean(storage: BooleanStorage, key: string, fallback: boolean) {
|
||||
try {
|
||||
const value = storage.getItem(key)
|
||||
if (value === 'true') return true
|
||||
if (value === 'false') return false
|
||||
} catch { /* storage may be unavailable */ }
|
||||
return fallback
|
||||
}
|
||||
|
||||
export function writeStoredBoolean(storage: BooleanStorage, key: string, value: boolean) {
|
||||
try { storage.setItem(key, String(value)) } catch { /* storage may be unavailable */ }
|
||||
}
|
||||
|
||||
export function dateKey(date: Date) {
|
||||
const y = date.getFullYear()
|
||||
const m = `${date.getMonth() + 1}`.padStart(2, '0')
|
||||
|
||||
Reference in New Issue
Block a user