mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
fix: resync aux timer names on project load, consolidate name handling
Addresses the review findings on the aux timer naming feature. - Aux timer names are project data, but they were only applied at bootstrap and on a settings POST. Loading another project left the previous project's names in the runtime store, so the controls and views disagreed with the settings panel until a restart. The names are now applied when a project is loaded, and patching the current project settings applies them and sends a settings refetch to the clients (loading a project already triggers a full refetch via the rundown). - Consolidate the name handling into a single normaliser in ontime-utils, used by the project file parser, the API validation and to build the default value. This creates the property when importing project files saved before the feature existed, and enforces the name length limit server side rather than only in the form. - loadNames normalises its input, so the runtime state is consistent regardless of the shape of the stored settings. - Clarify that auxTimerNames is ordered (index 0 is aux timer 1), and derive the settings form from the shared aux timer count. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WCZejVTzuAY3tHTE6nB3JH
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Settings } from 'ontime-types';
|
||||
import { normaliseAuxTimerNames } from 'ontime-utils';
|
||||
|
||||
export const ontimePlaceholderSettings: Settings = {
|
||||
version: '4.0.0',
|
||||
@@ -6,5 +7,5 @@ export const ontimePlaceholderSettings: Settings = {
|
||||
operatorKey: null,
|
||||
timeFormat: '24',
|
||||
language: 'en',
|
||||
auxTimerNames: ['', '', ''],
|
||||
auxTimerNames: normaliseAuxTimerNames(),
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Settings } from 'ontime-types';
|
||||
import { auxTimerNameMaxLength, numberOfAuxTimers } from 'ontime-utils';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
@@ -11,7 +12,8 @@ import useSettings from '../../../../common/hooks-query/useSettings';
|
||||
import { preventEscape } from '../../../../common/utils/keyEvent';
|
||||
import * as Panel from '../../panel-utils/PanelUtils';
|
||||
|
||||
const auxTimerIndexes = [1, 2, 3];
|
||||
/** zero based index of each aux timer, used to address the auxTimerNames array */
|
||||
const auxTimerIndexes = Array.from({ length: numberOfAuxTimers }, (_, index) => index);
|
||||
|
||||
export default function AuxTimerSettings() {
|
||||
const { data, status, refetch } = useSettings();
|
||||
@@ -79,8 +81,12 @@ export default function AuxTimerSettings() {
|
||||
<Panel.ListGroup>
|
||||
{auxTimerIndexes.map((index) => (
|
||||
<Panel.ListItem key={index}>
|
||||
<Panel.Field title={`Aux timer ${index}`} description={`Custom name for aux timer ${index}`} />
|
||||
<Input maxLength={30} placeholder={`Aux ${index}`} {...register(`auxTimerNames.${index - 1}`)} />
|
||||
<Panel.Field title={`Aux timer ${index + 1}`} description={`Custom name for aux timer ${index + 1}`} />
|
||||
<Input
|
||||
maxLength={auxTimerNameMaxLength}
|
||||
placeholder={`Aux ${index + 1}`}
|
||||
{...register(`auxTimerNames.${index}`)}
|
||||
/>
|
||||
</Panel.ListItem>
|
||||
))}
|
||||
</Panel.ListGroup>
|
||||
|
||||
Reference in New Issue
Block a user