From 4553e58b698dea3b1e0e396a5da90cc1130edf87 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 19 Jan 2022 12:52:16 +0300 Subject: [PATCH] Clean up Signed-off-by: Alex Andreev --- .../components/hotbar/hotbar-selector.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/hotbar/hotbar-selector.tsx b/src/renderer/components/hotbar/hotbar-selector.tsx index 77c2e77261..063435663c 100644 --- a/src/renderer/components/hotbar/hotbar-selector.tsx +++ b/src/renderer/components/hotbar/hotbar-selector.tsx @@ -16,10 +16,6 @@ import { withInjectables } from "@ogre-tools/injectable-react"; import commandOverlayInjectable from "../command-palette/command-overlay.injectable"; import { cssNames } from "../../utils"; -export interface HotbarSelectorProps { - hotbar: Hotbar; -} - interface Dependencies { hotbarManager: { switchToPrevious: () => void; @@ -30,26 +26,30 @@ interface Dependencies { openCommandOverlay: (component: React.ReactElement) => void; } +export interface HotbarSelectorProps extends Partial { + hotbar: Hotbar; +} + const NonInjectedHotbarSelector = observer(({ hotbar, hotbarManager, openCommandOverlay }: HotbarSelectorProps & Dependencies) => { const [tooltipVisible, setTooltipVisible] = useState(false); const tooltipTimeout = useRef(); - const clearTimer = () => { + function clearTimer() { clearTimeout(tooltipTimeout.current); }; - const onTooltipShow = () => { + function onTooltipShow() { setTooltipVisible(true); clearTimer(); tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500); }; - const onArrowClick = (switchTo: () => void) => { + function onArrowClick(switchTo: () => void) { onTooltipShow(); switchTo(); }; - const onMouseEvent = (event: React.MouseEvent) => { + function onMouseEvent(event: React.MouseEvent) { clearTimer(); setTooltipVisible(event.type == "mouseenter"); };