mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: add change log (#1734)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
@@ -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',
|
||||
{}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user