fix: flash screen when creating new page (#1657)

This commit is contained in:
Himself65
2023-03-22 02:36:49 -05:00
committed by GitHub
parent 17e29f50ab
commit e8b7ff527c
3 changed files with 19 additions and 6 deletions
@@ -0,0 +1,16 @@
import { atom, useAtomValue } from 'jotai';
import { currentPageIdAtom, workspacePreferredModeAtom } from '../../atoms';
const currentModeAtom = atom<'page' | 'edgeless'>(get => {
const pageId = get(currentPageIdAtom);
const record = get(workspacePreferredModeAtom);
if (pageId) return record[pageId] ?? 'page';
else {
return 'page';
}
});
export const useCurrentMode = () => {
return useAtomValue(currentModeAtom);
};