1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Do not convert store methods to arrow functions

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-04-06 12:44:08 +03:00
parent f5b10f2a38
commit 3fc72ebd9e
2 changed files with 13 additions and 12 deletions

View File

@ -285,7 +285,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
} }
} }
switchToPrevious = () => { switchToPrevious() {
let index = this.activeHotbarIndex - 1; let index = this.activeHotbarIndex - 1;
if (index < 0) { if (index < 0) {
@ -293,9 +293,9 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
} }
this.setActiveHotbar(index); this.setActiveHotbar(index);
}; }
switchToNext = () => { switchToNext() {
let index = this.activeHotbarIndex + 1; let index = this.activeHotbarIndex + 1;
if (index >= this.hotbars.length) { if (index >= this.hotbars.length) {
@ -303,7 +303,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
} }
this.setActiveHotbar(index); this.setActiveHotbar(index);
}; }
/** /**
* Checks if entity already pinned to the active hotbar * Checks if entity already pinned to the active hotbar

View File

@ -44,9 +44,14 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv
tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500); tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500);
} }
function onArrowClick(switchTo: () => void) { function onPrevClick() {
onTooltipShow(); onTooltipShow();
switchTo(); hotbarStore.switchToPrevious();
}
function onNextClick() {
onTooltipShow();
hotbarStore.switchToNext();
} }
function onMouseEvent(event: React.MouseEvent) { function onMouseEvent(event: React.MouseEvent) {
@ -56,11 +61,7 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv
return ( return (
<div className={styles.HotbarSelector}> <div className={styles.HotbarSelector}>
<Icon <Icon material="play_arrow" className={cssNames(styles.Icon, styles.previous)} onClick={onPrevClick}/>
material="play_arrow"
className={cssNames(styles.Icon, styles.previous)}
onClick={() => onArrowClick(hotbarStore.switchToPrevious)}
/>
<div className={styles.HotbarIndex}> <div className={styles.HotbarIndex}>
<Badge <Badge
id="hotbarIndex" id="hotbarIndex"
@ -79,7 +80,7 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv
{hotbar.name} {hotbar.name}
</Tooltip> </Tooltip>
</div> </div>
<Icon material="play_arrow" className={styles.Icon} onClick={() => onArrowClick(hotbarStore.switchToNext)} /> <Icon material="play_arrow" className={styles.Icon} onClick={onNextClick} />
</div> </div>
); );
}); });