webapp/src/stores/zine/seen.ts

19 lines
358 B
TypeScript
Raw Normal View History

2022-09-09 11:53:35 +00:00
import { persistentAtom } from '@nanostores/persistent'
import { action } from 'nanostores'
export const seen = persistentAtom<{ [slug: string]: Date }>(
'seen',
{},
{
encode: JSON.stringify,
decode: JSON.parse
}
)
export const addSeen =
(slug) => action(
seen,
'addSeen',
(s) => s.set({ ...s.get(), [slug]: Date.now() })
)