mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-06 23:09:08 +00:00
feat: notify ws clients on rundown changes (#327)
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
import { socket } from './WebsocketAdapter.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function to notify clients that the REST data is stale
|
||||||
|
* @param payload -- possible patch payload
|
||||||
|
*/
|
||||||
|
export function sendRefetch(payload: any | null = null) {
|
||||||
|
socket.send({
|
||||||
|
type: 'ontime-refetch',
|
||||||
|
payload,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { block as blockDef, delay as delayDef, event as eventDef } from '../mode
|
|||||||
import { MAX_EVENTS } from '../settings.js';
|
import { MAX_EVENTS } from '../settings.js';
|
||||||
import { EventLoader, eventLoader } from '../classes/event-loader/EventLoader.js';
|
import { EventLoader, eventLoader } from '../classes/event-loader/EventLoader.js';
|
||||||
import { eventTimer } from './TimerService.js';
|
import { eventTimer } from './TimerService.js';
|
||||||
|
import { sendRefetch } from '../adapters/websocketAux.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a list of IDs is in the current selection
|
* Checks if a list of IDs is in the current selection
|
||||||
@@ -145,6 +146,7 @@ export async function addEvent(eventData: Partial<OntimeEvent> | Partial<OntimeD
|
|||||||
}
|
}
|
||||||
updateTimer([id]);
|
updateTimer([id]);
|
||||||
updateChangeNumEvents();
|
updateChangeNumEvents();
|
||||||
|
sendRefetch();
|
||||||
return newEvent;
|
return newEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +158,7 @@ export async function editEvent(eventData) {
|
|||||||
}
|
}
|
||||||
const newEvent = await DataProvider.updateEventById(eventId, eventData);
|
const newEvent = await DataProvider.updateEventById(eventId, eventData);
|
||||||
updateTimer([eventId]);
|
updateTimer([eventId]);
|
||||||
|
sendRefetch();
|
||||||
return newEvent;
|
return newEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +171,7 @@ export async function deleteEvent(eventId) {
|
|||||||
await DataProvider.deleteEvent(eventId);
|
await DataProvider.deleteEvent(eventId);
|
||||||
updateTimer([eventId]);
|
updateTimer([eventId]);
|
||||||
updateChangeNumEvents();
|
updateChangeNumEvents();
|
||||||
|
sendRefetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,6 +182,7 @@ export async function deleteAllEvents() {
|
|||||||
await DataProvider.clearRundown();
|
await DataProvider.clearRundown();
|
||||||
updateTimer();
|
updateTimer();
|
||||||
updateChangeNumEvents();
|
updateChangeNumEvents();
|
||||||
|
sendRefetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,6 +207,7 @@ export async function reorderEvent(eventId, from, to) {
|
|||||||
// save rundown
|
// save rundown
|
||||||
await DataProvider.setRundown(rundown);
|
await DataProvider.setRundown(rundown);
|
||||||
updateTimer();
|
updateTimer();
|
||||||
|
sendRefetch();
|
||||||
return reorderedItem;
|
return reorderedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +263,7 @@ export async function applyDelay(eventId) {
|
|||||||
// update rundown
|
// update rundown
|
||||||
await DataProvider.setRundown(rundown);
|
await DataProvider.setRundown(rundown);
|
||||||
updateTimer();
|
updateTimer();
|
||||||
|
sendRefetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user