mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-10 17:46:05 +03:00
fix: state in lastVersionAtom
This commit is contained in:
parent
ee695bbcb9
commit
51a4bdc5e4
@ -1,10 +1,12 @@
|
||||
import { config } from '@affine/env';
|
||||
import { atomWithStorage } from 'jotai/utils';
|
||||
|
||||
export type Visibility = Record<string, boolean>;
|
||||
|
||||
const DEFAULT_VALUE = '0.0.0';
|
||||
|
||||
export const lastVersionAtom = atomWithStorage('lastVersion', DEFAULT_VALUE);
|
||||
export const lastVersionAtom = atomWithStorage(
|
||||
'lastVersion',
|
||||
config.gitVersion
|
||||
);
|
||||
|
||||
export const guideHiddenAtom = atomWithStorage<Visibility>('guideHidden', {});
|
||||
|
||||
|
@ -5,6 +5,7 @@ import 'fake-indexeddb/auto';
|
||||
|
||||
import assert from 'node:assert';
|
||||
|
||||
import { config } from '@affine/env';
|
||||
import {
|
||||
rootCurrentWorkspaceIdAtom,
|
||||
rootWorkspacesMetadataAtom,
|
||||
@ -282,7 +283,7 @@ describe('useIsFirstLoad', () => {
|
||||
test('useLastVersion', async () => {
|
||||
const lastVersion = renderHook(() => useLastVersion());
|
||||
const setLastVersion = lastVersion.result.current[1];
|
||||
expect(lastVersion.result.current[0]).toEqual('0.0.0');
|
||||
expect(lastVersion.result.current[0]).toEqual(config.gitVersion);
|
||||
setLastVersion('testVersion');
|
||||
lastVersion.rerender();
|
||||
expect(lastVersion.result.current[0]).toEqual('testVersion');
|
||||
|
@ -45,7 +45,6 @@ export function useTipsDisplayStatus() {
|
||||
|
||||
export function useUpdateTipsOnVersionChange() {
|
||||
const [lastVersion, setLastVersion] = useLastVersion();
|
||||
const currentVersion = config.gitVersion;
|
||||
const tipsDisplayStatus = useTipsDisplayStatus();
|
||||
const setPermanentlyHiddenTips = useSetAtom(guideHiddenAtom);
|
||||
const setHiddenUntilNextUpdateTips = useSetAtom(
|
||||
@ -53,6 +52,7 @@ export function useUpdateTipsOnVersionChange() {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const currentVersion = config.gitVersion;
|
||||
if (lastVersion !== currentVersion) {
|
||||
setLastVersion(currentVersion);
|
||||
const newHiddenUntilNextUpdateTips = { ...TIPS };
|
||||
@ -64,7 +64,6 @@ export function useUpdateTipsOnVersionChange() {
|
||||
setPermanentlyHiddenTips(newPermanentlyHiddenTips);
|
||||
}
|
||||
}, [
|
||||
currentVersion,
|
||||
lastVersion,
|
||||
setLastVersion,
|
||||
setPermanentlyHiddenTips,
|
||||
|
Loading…
Reference in New Issue
Block a user