From 9473880d2cc0f8ab9dbaf11ccc9c6e6b1b2e2177 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Fri, 27 Jun 2025 16:40:23 +0200 Subject: [PATCH] feat: notify clients to refetch custom fields --- apps/client/src/common/utils/socket.ts | 3 +++ apps/server/src/api-data/rundown/rundown.service.ts | 10 ++++++---- packages/types/src/api/websocket/refetch.type.ts | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/client/src/common/utils/socket.ts b/apps/client/src/common/utils/socket.ts index 47cf099af..d6890952e 100644 --- a/apps/client/src/common/utils/socket.ts +++ b/apps/client/src/common/utils/socket.ts @@ -152,6 +152,9 @@ export const connectSocket = () => { case RefetchKey.All: invalidateAllCaches(); break; + case RefetchKey.CustomFields: + ontimeQueryClient.invalidateQueries({ queryKey: CUSTOM_FIELDS }); + break; case RefetchKey.Rundown: if (revision === (ontimeQueryClient.getQueryData(RUNDOWN) as Rundown).revision) break; ontimeQueryClient.invalidateQueries({ queryKey: RUNDOWN }); diff --git a/apps/server/src/api-data/rundown/rundown.service.ts b/apps/server/src/api-data/rundown/rundown.service.ts index bb6152bc8..4a8e986a4 100644 --- a/apps/server/src/api-data/rundown/rundown.service.ts +++ b/apps/server/src/api-data/rundown/rundown.service.ts @@ -429,7 +429,9 @@ export async function createCustomField(customField: CustomField): Promise { + sendRefetch(RefetchKey.CustomFields); + }); return resultCustomFields; } @@ -470,7 +472,6 @@ export async function editCustomField(key: CustomFieldKey, newField: Partial { - // TODO: notify clients to refetch the custom fields notifyChanges(rundownMetadata, revision, { timer: true, external: true }); }); @@ -499,7 +500,6 @@ export async function deleteCustomField(key: CustomFieldKey): Promise { - // TODO: notify clients to refetch the custom fields notifyChanges(rundownMetadata, revision, { timer: true, external: true }); }); @@ -572,5 +572,7 @@ export async function initRundown(rundown: Readonly, customFields: Read updateRuntimeOnChange(rundownMetadata); // notify timer of change - notifyChanges(rundownMetadata, revision, { timer: true, external: true, reload: true }); + setImmediate(() => { + notifyChanges(rundownMetadata, revision, { timer: true, external: true, reload: true }); + }); } diff --git a/packages/types/src/api/websocket/refetch.type.ts b/packages/types/src/api/websocket/refetch.type.ts index 1e08f6f44..9618843ab 100644 --- a/packages/types/src/api/websocket/refetch.type.ts +++ b/packages/types/src/api/websocket/refetch.type.ts @@ -1,5 +1,6 @@ export enum RefetchKey { All = 'all', + CustomFields = 'custom-fields', Report = 'report', Rundown = 'rundown', ViewSettings = 'view-settings',