mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 22:49:18 +00:00
fix: state stale in integrations
This commit is contained in:
committed by
Carlos Valente
parent
9e04a1dcfa
commit
189cee0104
@@ -1,7 +1,7 @@
|
|||||||
import { LogOrigin } from 'ontime-types';
|
import { LogOrigin } from 'ontime-types';
|
||||||
|
|
||||||
import IIntegration, { TimerLifeCycleKey } from './IIntegration.js';
|
import IIntegration, { TimerLifeCycleKey } from './IIntegration.js';
|
||||||
import { eventStore } from '../../stores/EventStore.js';
|
import { getState } from '../../stores/runtimeState.js';
|
||||||
import { logger } from '../../classes/Logger.js';
|
import { logger } from '../../classes/Logger.js';
|
||||||
|
|
||||||
class IntegrationService {
|
class IntegrationService {
|
||||||
@@ -20,7 +20,14 @@ class IntegrationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch(action: TimerLifeCycleKey) {
|
dispatch(action: TimerLifeCycleKey) {
|
||||||
const state = eventStore.poll();
|
/**
|
||||||
|
* We currently get the state from the runtimeState store
|
||||||
|
* This solves an issue where the state is not updated until after the integrations have ran
|
||||||
|
* The workaround solves the issue with the tradeoff of
|
||||||
|
* - we do not have access to data outside runtimeState (eg: messages or auxtimers)
|
||||||
|
* - we couple the integrationService to runtimeState
|
||||||
|
*/
|
||||||
|
const state = getState();
|
||||||
this.integrations.forEach((integration) => {
|
this.integrations.forEach((integration) => {
|
||||||
integration.dispatch(action, state);
|
integration.dispatch(action, state);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ class RuntimeService {
|
|||||||
const success = runtimeState.load(event, timedEvents);
|
const success = runtimeState.load(event, timedEvents);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
// TODO: dispatch should happen after store update
|
||||||
|
// currently store update is handled in TimerService only
|
||||||
integrationService.dispatch(TimerLifeCycle.onLoad);
|
integrationService.dispatch(TimerLifeCycle.onLoad);
|
||||||
logger.info(LogOrigin.Playback, `Loaded event with ID ${event.id}`);
|
logger.info(LogOrigin.Playback, `Loaded event with ID ${event.id}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user