revert: lastVersionAtom atom (#2188)

This commit is contained in:
Himself65
2023-04-28 03:53:23 -05:00
committed by GitHub
parent fd4b664e4f
commit 903b6eaf30
3 changed files with 18 additions and 5 deletions
+15 -2
View File
@@ -1,11 +1,24 @@
import { config } from '@affine/env';
import { atomWithStorage } from 'jotai/utils';
export type Visibility = Record<string, boolean>;
const DEFAULT_VALUE = '0.0.0';
//atomWithStorage always uses initial value when first render
//https://github.com/pmndrs/jotai/discussions/1737
function getInitialValue() {
if (typeof window !== 'undefined') {
const storedValue = window.localStorage.getItem('lastVersion');
if (storedValue) {
return JSON.parse(storedValue);
}
}
return DEFAULT_VALUE;
}
export const lastVersionAtom = atomWithStorage(
'lastVersion',
config.gitVersion
getInitialValue()
);
export const guideHiddenAtom = atomWithStorage<Visibility>('guideHidden', {});