♻️(frontend) remove redundant formatLongPressLabel helper
Use i18next interpolation directly in useShortcutFormatting
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user