mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 17:16:16 +08:00
refactor: mode atom (#3221)
This commit is contained in:
@@ -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);
|
||||
};
|
||||
Reference in New Issue
Block a user