mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 02:13:48 +00:00
refactor: rename external message to secondary message
This commit is contained in:
committed by
Carlos Valente
parent
0aeec12ccd
commit
3cd6cd2f55
@@ -158,10 +158,10 @@ describe('parseOutput', () => {
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: 'external',
|
||||
secondarySource: 'secondary',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: 'external',
|
||||
secondarySource: 'secondary',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -254,6 +254,6 @@ function indeterminateBooleanString(value: string): boolean | undefined {
|
||||
*/
|
||||
function chooseSecondarySource(value: string): SecondarySource {
|
||||
if (value === 'aux') return 'aux';
|
||||
if (value === 'external') return 'external';
|
||||
if (value === 'secondary') return 'secondary';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { LogOrigin, OntimeAction } from 'ontime-types';
|
||||
|
||||
import { logger } from '../../../classes/Logger.js';
|
||||
import { auxTimerService } from '../../../services/aux-timer-service/AuxTimerService.js';
|
||||
import * as messageService from '../../../services/message-service/MessageService.js';
|
||||
import * as messageService from '../../../services/message-service/message.service.js';
|
||||
|
||||
export function toOntimeAction(action: OntimeAction) {
|
||||
const actionType = action.action;
|
||||
|
||||
@@ -13,8 +13,8 @@ import { DeepPartial } from 'ts-essentials';
|
||||
|
||||
import { ONTIME_VERSION } from '../ONTIME_VERSION.js';
|
||||
import { auxTimerService } from '../services/aux-timer-service/AuxTimerService.js';
|
||||
import * as messageService from '../services/message-service/MessageService.js';
|
||||
import { validateMessage, validateTimerMessage } from '../services/message-service/messageUtils.js';
|
||||
import * as messageService from '../services/message-service/message.service.js';
|
||||
import { validateMessage, validateTimerMessage } from '../services/message-service/message.utils.js';
|
||||
import { runtimeService } from '../services/runtime-service/RuntimeService.js';
|
||||
import { eventStore } from '../stores/EventStore.js';
|
||||
import * as assert from '../utils/assert.js';
|
||||
@@ -101,7 +101,7 @@ const actionHandlers: Record<ApiAction, ActionHandler> = {
|
||||
|
||||
const patch: DeepPartial<MessageState> = {
|
||||
timer: 'timer' in payload ? validateTimerMessage(payload.timer) : undefined,
|
||||
external: 'external' in payload ? validateMessage(payload.external) : undefined,
|
||||
secondary: 'secondary' in payload ? validateMessage(payload.secondary) : undefined,
|
||||
};
|
||||
|
||||
const newMessage = messageService.patch(patch);
|
||||
|
||||
@@ -33,7 +33,7 @@ import { populateStyles } from './setup/loadStyles.js';
|
||||
import { eventStore } from './stores/EventStore.js';
|
||||
import { runtimeService } from './services/runtime-service/RuntimeService.js';
|
||||
import { restoreService } from './services/RestoreService.js';
|
||||
import * as messageService from './services/message-service/MessageService.js';
|
||||
import * as messageService from './services/message-service/message.service.js';
|
||||
import { populateDemo } from './setup/loadDemo.js';
|
||||
import { getState } from './stores/runtimeState.js';
|
||||
import { initRundown } from './api-data/rundown/rundown.service.js';
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
import { RuntimeStore } from 'ontime-types';
|
||||
|
||||
import * as messageService from '../MessageService.js';
|
||||
import * as messageService from '../message.service.js';
|
||||
|
||||
describe('MessageService', () => {
|
||||
let store: Partial<RuntimeStore>;
|
||||
@@ -17,12 +17,12 @@ describe('MessageService', () => {
|
||||
it('should patch the message state', () => {
|
||||
const newState = messageService.patch({
|
||||
timer: { text: 'new text', visible: true },
|
||||
external: 'external',
|
||||
secondary: 'secondary',
|
||||
});
|
||||
|
||||
expect(newState).toMatchObject({
|
||||
timer: { text: 'new text', visible: true, blackout: false, blink: false, secondarySource: null },
|
||||
external: 'external',
|
||||
secondary: 'secondary',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('MessageService', () => {
|
||||
|
||||
expect(newState).toMatchObject({
|
||||
timer: { text: 'initial text', visible: true, blackout: false, blink: false, secondarySource: null },
|
||||
external: '',
|
||||
secondary: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { validateMessage, validateTimerMessage } from '../messageUtils.js';
|
||||
import { validateMessage, validateTimerMessage } from '../message.utils.js';
|
||||
|
||||
describe('validateMessage()', () => {
|
||||
it('returns a valid Message object', () => {
|
||||
+1
-1
@@ -43,7 +43,7 @@ export function patch(patch: DeepPartial<MessageState>): MessageState {
|
||||
const newState = { ...getState() };
|
||||
|
||||
if ('timer' in patch) newState.timer = { ...newState.timer, ...patch.timer };
|
||||
if ('external' in patch && patch.external !== undefined) newState.external = patch.external;
|
||||
if ('secondary' in patch && patch.secondary !== undefined) newState.secondary = patch.secondary;
|
||||
|
||||
throttledSet('message', newState);
|
||||
return newState;
|
||||
+1
-1
@@ -33,7 +33,7 @@ export function validateTimerMessage(message: unknown): Partial<TimerMessage> {
|
||||
* Asserts that the secondary value is one of the permitted values
|
||||
*/
|
||||
function assertSecondary(source: unknown): source is TimerMessage['secondarySource'] {
|
||||
return source === 'aux' || source === 'external' || source === null;
|
||||
return source === 'aux' || source === 'secondary' || source === null;
|
||||
}
|
||||
|
||||
/**
|
||||
Reference in New Issue
Block a user