feat: add change log (#1734)

Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
JimmFly
2023-03-31 04:17:36 +08:00
committed by GitHub
parent 91c32b6715
commit c9bd4e34b3
12 changed files with 292 additions and 49 deletions

View File

@@ -1,5 +1,28 @@
import { atom } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
export const isFirstLoadAtom = atomWithStorage<boolean>('isFirstLoad', true);
export const openTipsAtom = atom<boolean>(false);
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',
getInitialValue()
);
export const guideHiddenAtom = atomWithStorage<Visibility>('guideHidden', {});
export const guideHiddenUntilNextUpdateAtom = atomWithStorage<Visibility>(
'guideHiddenUntilNextUpdate',
{}
);