mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 18:03:47 +00:00
refactor: simplify l3
This commit is contained in:
committed by
Carlos Valente
parent
b14ac07568
commit
dd81b92584
@@ -66,7 +66,6 @@ const actionHandlers: Record<string, ActionHandler> = {
|
||||
|
||||
const patch: DeepPartial<MessageState> = {
|
||||
timer: 'timer' in payload ? validateTimerMessage(payload.timer) : undefined,
|
||||
lower: 'lower' in payload ? validateMessage(payload.lower) : undefined,
|
||||
external: 'external' in payload ? validateMessage(payload.external) : undefined,
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ let instance: MessageService | null = null;
|
||||
|
||||
class MessageService {
|
||||
timer: TimerMessage;
|
||||
lower: Message;
|
||||
external: Message;
|
||||
|
||||
private throttledSet: PublishFn;
|
||||
@@ -37,11 +36,6 @@ class MessageService {
|
||||
blackout: false,
|
||||
};
|
||||
|
||||
this.lower = {
|
||||
text: '',
|
||||
visible: false,
|
||||
};
|
||||
|
||||
this.external = {
|
||||
text: '',
|
||||
visible: false,
|
||||
@@ -56,14 +50,12 @@ class MessageService {
|
||||
getState(): MessageState {
|
||||
return {
|
||||
timer: this.timer,
|
||||
lower: this.lower,
|
||||
external: this.external,
|
||||
};
|
||||
}
|
||||
|
||||
patch(message: DeepPartial<MessageState>) {
|
||||
if (message.timer) this.timer = { ...this.timer, ...message.timer };
|
||||
if (message.lower) this.lower = { ...this.lower, ...message.lower };
|
||||
if (message.external) this.external = { ...this.external, ...message.external };
|
||||
|
||||
const newState = this.getState();
|
||||
|
||||
@@ -14,7 +14,6 @@ describe('MessageService', () => {
|
||||
it('should patch the message state', () => {
|
||||
const message = {
|
||||
timer: { text: 'new text', visible: true },
|
||||
lower: { text: 'lower text' },
|
||||
external: { visible: true },
|
||||
};
|
||||
|
||||
@@ -22,10 +21,6 @@ describe('MessageService', () => {
|
||||
|
||||
expect(newState).toEqual({
|
||||
timer: { text: 'new text', visible: true, blackout: false, blink: false },
|
||||
lower: {
|
||||
text: 'lower text',
|
||||
visible: false,
|
||||
},
|
||||
external: {
|
||||
text: '',
|
||||
visible: true,
|
||||
@@ -42,10 +37,6 @@ describe('MessageService', () => {
|
||||
|
||||
expect(newState).toEqual({
|
||||
timer: { text: 'initial text', visible: true, blackout: false, blink: false },
|
||||
lower: {
|
||||
text: '',
|
||||
visible: false,
|
||||
},
|
||||
external: {
|
||||
text: '',
|
||||
visible: false,
|
||||
|
||||
Reference in New Issue
Block a user