mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
refactor: emit load event on reload
This commit is contained in:
committed by
Carlos Valente
parent
84792bc00d
commit
00d34eec9b
@@ -476,7 +476,13 @@ class RuntimeService {
|
|||||||
reload() {
|
reload() {
|
||||||
const state = runtimeState.getState();
|
const state = runtimeState.getState();
|
||||||
if (state.eventNow) {
|
if (state.eventNow) {
|
||||||
runtimeState.reload();
|
const eventId = runtimeState.reload();
|
||||||
|
if (eventId) {
|
||||||
|
logger.info(LogOrigin.Playback, `Loaded event with ID ${eventId}`);
|
||||||
|
process.nextTick(() => {
|
||||||
|
integrationService.dispatch(TimerLifeCycle.onLoad);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ export function resume(restorePoint: RestorePoint, event: OntimeEvent, rundown:
|
|||||||
* @param {OntimeEvent} event only passed if we are changing the data if a playing timer
|
* @param {OntimeEvent} event only passed if we are changing the data if a playing timer
|
||||||
*/
|
*/
|
||||||
export function reload(event?: OntimeEvent) {
|
export function reload(event?: OntimeEvent) {
|
||||||
|
// we only pass an event for hot reloading, ie: the event has changed
|
||||||
if (event) {
|
if (event) {
|
||||||
runtimeState.eventNow = event;
|
runtimeState.eventNow = event;
|
||||||
|
|
||||||
@@ -243,7 +244,7 @@ export function reload(event?: OntimeEvent) {
|
|||||||
runtimeState.timer.duration = calculateDuration(runtimeState.eventNow.timeStart, runtimeState.eventNow.timeEnd);
|
runtimeState.timer.duration = calculateDuration(runtimeState.eventNow.timeStart, runtimeState.eventNow.timeEnd);
|
||||||
runtimeState.timer.current = getCurrent(runtimeState);
|
runtimeState.timer.current = getCurrent(runtimeState);
|
||||||
runtimeState.timer.expectedFinish = getExpectedFinish(runtimeState);
|
runtimeState.timer.expectedFinish = getExpectedFinish(runtimeState);
|
||||||
return;
|
return runtimeState.eventNow.id;
|
||||||
}
|
}
|
||||||
runtimeState.timer.playback = Playback.Armed;
|
runtimeState.timer.playback = Playback.Armed;
|
||||||
|
|
||||||
@@ -257,6 +258,7 @@ export function reload(event?: OntimeEvent) {
|
|||||||
runtimeState.timer.addedTime = 0;
|
runtimeState.timer.addedTime = 0;
|
||||||
|
|
||||||
runtimeState.timer.expectedFinish = getExpectedFinish(runtimeState);
|
runtimeState.timer.expectedFinish = getExpectedFinish(runtimeState);
|
||||||
|
return runtimeState.eventNow.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user