Skip to content

Commit 222ecca

Browse files
committed
feat(layout): hook to track the loaded layout
1 parent 8c3f5a5 commit 222ecca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

electron/renderer/hooks/layouts.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import type { Maybe } from '../../common/types.js';
44
import { runInBackground } from '../lib/async/run-in-background.js';
55
import { usePubSub, useSubscribe } from './pubsub.jsx';
66

7+
export const useLoadedLayout = (): Maybe<Layout> => {
8+
const [layoutName, setLayoutName] = useState<string>('default');
9+
const layout = useGetLayout(layoutName);
10+
11+
useSubscribe(['layout:load'], (layoutName: string) => {
12+
setLayoutName(layoutName);
13+
});
14+
15+
return layout;
16+
};
17+
718
/**
819
* Gets the layout configuration for a given layout name.
920
* Automatically refreshes the layout when it is saved or deleted.

0 commit comments

Comments
 (0)