mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
25 lines
617 B
TypeScript
25 lines
617 B
TypeScript
import { useAtom } from 'jotai';
|
|
import { useCallback } from 'react';
|
|
|
|
import { currentPageIdAtom, currentWorkspaceIdAtom } from '../../atoms';
|
|
import { RemWorkspace } from '../../shared';
|
|
import { useWorkspace } from '../use-workspace';
|
|
|
|
export function useCurrentWorkspace(): [
|
|
RemWorkspace | null,
|
|
(id: string | null) => void
|
|
] {
|
|
const [id, setId] = useAtom(currentWorkspaceIdAtom);
|
|
const [, setPageId] = useAtom(currentPageIdAtom);
|
|
return [
|
|
useWorkspace(id),
|
|
useCallback(
|
|
(id: string | null) => {
|
|
setPageId(null);
|
|
setId(id);
|
|
},
|
|
[setId, setPageId]
|
|
),
|
|
];
|
|
}
|