mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 23:26:30 +08:00
18 lines
499 B
TypeScript
18 lines
499 B
TypeScript
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);
|
|
};
|