mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 12:53:32 +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,9 +1,10 @@
|
||||
import { copyFile } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
|
||||
import { DatabaseModel, LogOrigin, ProjectFileListResponse } from 'ontime-types';
|
||||
import { DatabaseModel, LogOrigin, ProjectFileListResponse, RefetchKey } from 'ontime-types';
|
||||
import { getErrorMessage, getFirstRundown } from 'ontime-utils';
|
||||
|
||||
import { sendRefetch } from '../../adapters/WebsocketAdapter.js';
|
||||
import { parseCustomFields } from '../../api-data/custom-fields/customFields.parser.js';
|
||||
import { parseDatabaseModel } from '../../api-data/db/db.parser.js';
|
||||
import { getCurrentRundown } from '../../api-data/rundown/rundown.dao.js';
|
||||
@@ -28,6 +29,7 @@ import {
|
||||
removeFileExtension,
|
||||
} from '../../utils/fileManagement.js';
|
||||
import { getLastLoaded, isLastLoadedProject, setLastLoaded } from '../app-state-service/AppStateService.js';
|
||||
import { auxTimerService } from '../aux-timer-service/AuxTimerService.js';
|
||||
import { runtimeService } from '../runtime-service/runtime.service.js';
|
||||
import {
|
||||
doesProjectExist,
|
||||
@@ -88,12 +90,16 @@ async function loadProject(projectData: DatabaseModel, fileName: string, rundown
|
||||
// stop the runtime service
|
||||
runtimeService.stop();
|
||||
|
||||
// the aux timer names belong to the project, apply the ones from the newly loaded project
|
||||
auxTimerService.loadNames(projectData.settings.auxTimerNames);
|
||||
|
||||
// load the rundown given by key otherwise load the first in the project
|
||||
const rundown =
|
||||
rundownId && rundownId in projectData.rundowns
|
||||
? projectData.rundowns[rundownId]
|
||||
: getFirstRundown(projectData.rundowns);
|
||||
|
||||
// initialising the rundown with reload sends a refetch to the clients
|
||||
await initRundown(rundown, projectData.customFields, true);
|
||||
|
||||
// persist the project selection
|
||||
@@ -346,6 +352,12 @@ export async function patchCurrentProject(data: Partial<DatabaseModel>) {
|
||||
// we can pass some stuff straight to the data provider
|
||||
await getDataProvider().mergeIntoData(rest);
|
||||
|
||||
// the settings may contain new aux timer names, apply them and notify the clients
|
||||
if (rest.settings) {
|
||||
auxTimerService.loadNames(getDataProvider().getSettings().auxTimerNames);
|
||||
sendRefetch(RefetchKey.Settings);
|
||||
}
|
||||
|
||||
// the rundown depends on custom fields
|
||||
// so custom fields needs to be checked first
|
||||
if (customFields) {
|
||||
|
||||
Reference in New Issue
Block a user