refactor: mode atom (#3221)

This commit is contained in:
Alex Yang
2023-07-13 23:11:00 +08:00
committed by GitHub
parent d18df12951
commit 492852ba0c
4 changed files with 18 additions and 22 deletions
@@ -1,17 +0,0 @@
import { currentPageIdAtom } from '@toeverything/plugin-infra/manager';
import { atom, useAtomValue } from 'jotai';
import { pageSettingFamily } from '../../atoms';
const currentModeAtom = atom<'page' | 'edgeless'>(get => {
const pageId = get(currentPageIdAtom);
// fixme(himself65): pageId should not be null
if (!pageId) {
return 'page';
}
return get(pageSettingFamily(pageId))?.mode ?? 'page';
});
export const useCurrentMode = () => {
return useAtomValue(currentModeAtom);
};