feat: notify clients to refetch custom fields

This commit is contained in:
Carlos Valente
2025-06-27 16:40:23 +02:00
committed by Carlos Valente
parent 473f50b493
commit 9473880d2c
3 changed files with 10 additions and 4 deletions
+3
View File
@@ -152,6 +152,9 @@ export const connectSocket = () => {
case RefetchKey.All: case RefetchKey.All:
invalidateAllCaches(); invalidateAllCaches();
break; break;
case RefetchKey.CustomFields:
ontimeQueryClient.invalidateQueries({ queryKey: CUSTOM_FIELDS });
break;
case RefetchKey.Rundown: case RefetchKey.Rundown:
if (revision === (ontimeQueryClient.getQueryData(RUNDOWN) as Rundown).revision) break; if (revision === (ontimeQueryClient.getQueryData(RUNDOWN) as Rundown).revision) break;
ontimeQueryClient.invalidateQueries({ queryKey: RUNDOWN }); ontimeQueryClient.invalidateQueries({ queryKey: RUNDOWN });
@@ -429,7 +429,9 @@ export async function createCustomField(customField: CustomField): Promise<Custo
// Adding a custom field has no immediate implications on the rundown // Adding a custom field has no immediate implications on the rundown
const { customFields: resultCustomFields } = commit(false); const { customFields: resultCustomFields } = commit(false);
// TODO: notify clients to refetch the custom fields setImmediate(() => {
sendRefetch(RefetchKey.CustomFields);
});
return resultCustomFields; return resultCustomFields;
} }
@@ -470,7 +472,6 @@ export async function editCustomField(key: CustomFieldKey, newField: Partial<Cus
// schedule the side effects // schedule the side effects
setImmediate(() => { setImmediate(() => {
// TODO: notify clients to refetch the custom fields
notifyChanges(rundownMetadata, revision, { timer: true, external: true }); notifyChanges(rundownMetadata, revision, { timer: true, external: true });
}); });
@@ -499,7 +500,6 @@ export async function deleteCustomField(key: CustomFieldKey): Promise<CustomFiel
// schedule the side effects // schedule the side effects
setImmediate(() => { setImmediate(() => {
// TODO: notify clients to refetch the custom fields
notifyChanges(rundownMetadata, revision, { timer: true, external: true }); notifyChanges(rundownMetadata, revision, { timer: true, external: true });
}); });
@@ -572,5 +572,7 @@ export async function initRundown(rundown: Readonly<Rundown>, customFields: Read
updateRuntimeOnChange(rundownMetadata); updateRuntimeOnChange(rundownMetadata);
// notify timer of change // notify timer of change
notifyChanges(rundownMetadata, revision, { timer: true, external: true, reload: true }); setImmediate(() => {
notifyChanges(rundownMetadata, revision, { timer: true, external: true, reload: true });
});
} }
@@ -1,5 +1,6 @@
export enum RefetchKey { export enum RefetchKey {
All = 'all', All = 'all',
CustomFields = 'custom-fields',
Report = 'report', Report = 'report',
Rundown = 'rundown', Rundown = 'rundown',
ViewSettings = 'view-settings', ViewSettings = 'view-settings',