1369f3b967
* WIP persistence work * Fix up close date filter, kill custom scroll restoration * Use built-in Next.js scroll restoration machinery * Tweaking stuff * Implement 'history state' idea * Clean up and unify persistent state stores * Respect options for persisting contract search * Fix typing in common lib * Clean up console logging
25 lines
512 B
TypeScript
25 lines
512 B
TypeScript
export const safeLocalStorage = () =>
|
|
isLocalStorage() ? localStorage : undefined
|
|
export const safeSessionStorage = () =>
|
|
isSessionStorage() ? sessionStorage : undefined
|
|
|
|
const isLocalStorage = () => {
|
|
try {
|
|
localStorage.getItem('test')
|
|
localStorage.setItem('hi', 'mom')
|
|
return true
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
const isSessionStorage = () => {
|
|
try {
|
|
sessionStorage.getItem('test')
|
|
sessionStorage.setItem('hi', 'mom')
|
|
return true
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
}
|