From 793da547636dfe4dcde726bee41cc4692a03fb5a Mon Sep 17 00:00:00 2001 From: Jim Ehrismann Date: Fri, 14 May 2021 11:19:22 -0400 Subject: [PATCH] tweaks to hotbarDisplayLabel() Signed-off-by: Jim Ehrismann --- .../components/hotbar/hotbar-display-label.ts | 23 ++++++++++--------- .../components/hotbar/hotbar-selector.tsx | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/renderer/components/hotbar/hotbar-display-label.ts b/src/renderer/components/hotbar/hotbar-display-label.ts index 6f7506af6e..0489e2600f 100644 --- a/src/renderer/components/hotbar/hotbar-display-label.ts +++ b/src/renderer/components/hotbar/hotbar-display-label.ts @@ -21,15 +21,16 @@ import { HotbarStore } from "../../../common/hotbar-store"; -export function hotbarDisplayLabel(id: string, withName = true) : string { - const hotbarStore = HotbarStore.getInstance(); - const index = hotbarStore.hotbarIndex(id) + 1; - - if (withName) { - const hotbar = hotbarStore.getById(id); - - return `${index}: ${hotbar.name}`; - } - - return index.toString(); +function hotbarIndex(id: string) { + return HotbarStore.getInstance().hotbarIndex(id) + 1; +} + +export function hotbarDisplayLabel(id: string) : string { + const hotbar = HotbarStore.getInstance().getById(id); + + return `${hotbarIndex(id)}: ${hotbar.name}`; +} + +export function hotbarDisplayIndex(id: string) : string { + return hotbarIndex(id).toString(); } diff --git a/src/renderer/components/hotbar/hotbar-selector.tsx b/src/renderer/components/hotbar/hotbar-selector.tsx index 6d713749ec..63041a5d38 100644 --- a/src/renderer/components/hotbar/hotbar-selector.tsx +++ b/src/renderer/components/hotbar/hotbar-selector.tsx @@ -26,7 +26,7 @@ import { Badge } from "../badge"; import { Hotbar, HotbarStore } from "../../../common/hotbar-store"; import { CommandOverlay } from "../command-palette"; import { HotbarSwitchCommand } from "./hotbar-switch-command"; -import { hotbarDisplayLabel } from "./hotbar-display-label"; +import { hotbarDisplayIndex } from "./hotbar-display-label"; import { MaterialTooltip } from "../+catalog/material-tooltip/material-tooltip"; interface Props { @@ -44,7 +44,7 @@ export function HotbarSelector({ hotbar }: Props) { CommandOverlay.open()} />