From 3fc72ebd9e672771737bbfeb200e7626510732c9 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 6 Apr 2022 12:44:08 +0300 Subject: [PATCH] Do not convert store methods to arrow functions Signed-off-by: Alex Andreev --- src/common/hotbar-store.ts | 8 ++++---- .../components/hotbar/hotbar-selector.tsx | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/common/hotbar-store.ts b/src/common/hotbar-store.ts index 3126b13413..7de8ff7617 100644 --- a/src/common/hotbar-store.ts +++ b/src/common/hotbar-store.ts @@ -285,7 +285,7 @@ export class HotbarStore extends BaseStore { } } - switchToPrevious = () => { + switchToPrevious() { let index = this.activeHotbarIndex - 1; if (index < 0) { @@ -293,9 +293,9 @@ export class HotbarStore extends BaseStore { } this.setActiveHotbar(index); - }; + } - switchToNext = () => { + switchToNext() { let index = this.activeHotbarIndex + 1; if (index >= this.hotbars.length) { @@ -303,7 +303,7 @@ export class HotbarStore extends BaseStore { } this.setActiveHotbar(index); - }; + } /** * Checks if entity already pinned to the active hotbar diff --git a/src/renderer/components/hotbar/hotbar-selector.tsx b/src/renderer/components/hotbar/hotbar-selector.tsx index 59e39605e2..d3d6b314e0 100644 --- a/src/renderer/components/hotbar/hotbar-selector.tsx +++ b/src/renderer/components/hotbar/hotbar-selector.tsx @@ -44,9 +44,14 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500); } - function onArrowClick(switchTo: () => void) { + function onPrevClick() { onTooltipShow(); - switchTo(); + hotbarStore.switchToPrevious(); + } + + function onNextClick() { + onTooltipShow(); + hotbarStore.switchToNext(); } function onMouseEvent(event: React.MouseEvent) { @@ -56,11 +61,7 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv return (
- onArrowClick(hotbarStore.switchToPrevious)} - /> +
- onArrowClick(hotbarStore.switchToNext)} /> +
); });