manifold/web/lib/firebase/seen-contracts.ts
2022-08-09 15:19:33 -07:00

23 lines
538 B
TypeScript

import { mapValues } from 'lodash'
const key = 'feed-seen-contracts'
export const pushSeenContract = (contractId: string) => {
const newSeenContracts = {
...getSeenContracts(),
[contractId]: Date.now(),
}
setSeenContracts(newSeenContracts)
}
export const setSeenContracts = (timestampsById: { [k: string]: number }) => {
localStorage.setItem(key, JSON.stringify(timestampsById))
}
export const getSeenContracts = () => {
return mapValues(
JSON.parse(localStorage.getItem(key) ?? '{}'),
(time) => +time
)
}