1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/app-desktop/gui/Sidebar/hooks/useSidebarCommandHandler.ts

25 lines
635 B
TypeScript
Raw Normal View History

import CommandService from '@joplin/lib/services/CommandService';
import { useEffect } from 'react';
import commands from '../commands';
import { SidebarCommandRuntimeProps } from '../types';
interface Props {
focusSidebar: ()=> void;
}
const useSidebarCommandHandler = ({ focusSidebar }: Props) => {
useEffect(() => {
const runtimeProps: SidebarCommandRuntimeProps = {
focusSidebar,
};
CommandService.instance().componentRegisterCommands(runtimeProps, commands);
return () => {
CommandService.instance().componentUnregisterCommands(commands);
};
}, [focusSidebar]);
};
export default useSidebarCommandHandler;