From 2cdf19de777bd8af34f8e5769caa35d2a503ec49 Mon Sep 17 00:00:00 2001 From: Cyril Date: Tue, 24 Feb 2026 09:16:16 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20remove=20redunda?= =?UTF-8?q?nt=20formatLongPressLabel=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use i18next interpolation directly in useShortcutFormatting --- src/frontend/src/features/shortcuts/formatLabels.ts | 11 +---------- .../features/shortcuts/hooks/useShortcutFormatting.ts | 11 ++--------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/frontend/src/features/shortcuts/formatLabels.ts b/src/frontend/src/features/shortcuts/formatLabels.ts index 98123e32..d3a59f94 100644 --- a/src/frontend/src/features/shortcuts/formatLabels.ts +++ b/src/frontend/src/features/shortcuts/formatLabels.ts @@ -14,7 +14,7 @@ export const formatShortcutLabel = (shortcut?: Shortcut) => { return parts.join('+') } -// SR-friendly label for a shortcut (reads “Control plus D”). +// SR-friendly label for a shortcut (reads "Control plus D"). export const formatShortcutLabelForSR = ( shortcut: Shortcut | undefined, { @@ -57,12 +57,3 @@ export const getKeyLabelFromCode = (code?: string) => { if (code.startsWith('Arrow')) return code.slice(5) // Up, Down, Left, Right return code } - -// Long-press label (visual or SR), e.g. “Hold V”. -export const formatLongPressLabel = ( - codeLabel: string, - holdTemplate: string -) => { - if (!codeLabel) return holdTemplate.replace('{{key}}', '?') - return holdTemplate.replace('{{key}}', codeLabel) -} diff --git a/src/frontend/src/features/shortcuts/hooks/useShortcutFormatting.ts b/src/frontend/src/features/shortcuts/hooks/useShortcutFormatting.ts index 1c747da0..4f1fcaa5 100644 --- a/src/frontend/src/features/shortcuts/hooks/useShortcutFormatting.ts +++ b/src/frontend/src/features/shortcuts/hooks/useShortcutFormatting.ts @@ -4,7 +4,6 @@ import { Shortcut } from '../types' import { formatShortcutLabel, formatShortcutLabelForSR, - formatLongPressLabel, getKeyLabelFromCode, } from '../formatLabels' @@ -15,10 +14,7 @@ export const useShortcutFormatting = () => { (shortcut?: Shortcut, code?: string, kind?: string) => { if (code && kind === 'longPress') { const label = getKeyLabelFromCode(code) - return formatLongPressLabel( - label, - t('shortcutsPanel.visual.hold', { key: '{{key}}' }) - ) + return t('shortcutsPanel.visual.hold', { key: label || '?' }) } return formatShortcutLabel(shortcut) }, @@ -29,10 +25,7 @@ export const useShortcutFormatting = () => { (shortcut?: Shortcut, code?: string, kind?: string) => { if (code && kind === 'longPress') { const label = getKeyLabelFromCode(code) - return formatLongPressLabel( - label, - t('shortcutsPanel.sr.hold', { key: '{{key}}' }) - ) + return t('shortcutsPanel.sr.hold', { key: label || '?' }) } return formatShortcutLabelForSR(shortcut, { controlLabel: t('shortcutsPanel.sr.control'),