diff --git a/apps/client/src/common/hooks/useSocket.ts b/apps/client/src/common/hooks/useSocket.ts index 97f9b9448..24753b5df 100644 --- a/apps/client/src/common/hooks/useSocket.ts +++ b/apps/client/src/common/hooks/useSocket.ts @@ -95,6 +95,14 @@ export const useAuxTimersTime = createSelector((state: RuntimeStore) => { }; }); +export const useAuxTimersName = createSelector((state: RuntimeStore) => { + return { + aux1: state.auxtimer1.name, + aux2: state.auxtimer2.name, + aux3: state.auxtimer3.name, + }; +}); + export const useAuxTimerTime = (index: number) => createSelector((state: RuntimeStore) => { if (index === 1) return state.auxtimer1.current; @@ -108,15 +116,18 @@ export const useAuxTimerControl = (index: number) => return { playback: state.auxtimer1.playback, direction: state.auxtimer1.direction, + name: state.auxtimer1.name, }; if (index === 2) return { playback: state.auxtimer2.playback, direction: state.auxtimer2.direction, + name: state.auxtimer2.name, }; return { playback: state.auxtimer3.playback, direction: state.auxtimer3.direction, + name: state.auxtimer3.name, }; })(); diff --git a/apps/client/src/common/utils/auxTimerUtils.ts b/apps/client/src/common/utils/auxTimerUtils.ts index 2a2485707..4acf8caf3 100644 --- a/apps/client/src/common/utils/auxTimerUtils.ts +++ b/apps/client/src/common/utils/auxTimerUtils.ts @@ -1,11 +1,10 @@ /** * Resolves the display label for an aux timer. * Falls back to the provided default when no custom name is set. - * @param names - the auxTimerNames array from settings (indexed 0-based) - * @param index - 1-based aux timer index (1, 2, 3) + * @param name - the aux timer's custom name (from the runtime store) * @param fallback - label to use when no custom name is set */ -export function getAuxTimerLabel(names: string[] | undefined, index: number, fallback: string): string { - const custom = names?.[index - 1]?.trim(); +export function getAuxTimerLabel(name: string | undefined, fallback: string): string { + const custom = name?.trim(); return custom ? custom : fallback; } diff --git a/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx b/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx index 24e982d01..c7527d1ab 100644 --- a/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx +++ b/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx @@ -4,8 +4,6 @@ import { UseFormRegister, UseFormSetValue, UseFormWatch } from 'react-hook-form' import Input from '../../../../common/components/input/input/Input'; import Select from '../../../../common/components/select/Select'; -import useSettings from '../../../../common/hooks-query/useSettings'; -import { getAuxTimerLabel } from '../../../../common/utils/auxTimerUtils'; import * as Panel from '../../panel-utils/PanelUtils'; import TemplateInput from './template-input/TemplateInput'; @@ -36,15 +34,12 @@ export default function OntimeActionForm({ watch, }: PropsWithChildren) { const [selectedAction, setSelectedAction] = useState(value); - const { data: settings } = useSettings(); const handleSetAction = (value: OntimeActionKey) => { setValue(`outputs.${index}.action`, value, { shouldDirty: true }); setSelectedAction(value); }; - const auxLabel = (auxIndex: number) => getAuxTimerLabel(settings.auxTimerNames, auxIndex, `Aux ${auxIndex}`); - return (