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

25 lines
635 B
TypeScript

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;