mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
refactor: share store initial state
This commit is contained in:
committed by
Carlos Valente
parent
b73448f827
commit
a4aa513d1f
@@ -1,58 +1,7 @@
|
|||||||
import isEqual from 'react-fast-compare';
|
import isEqual from 'react-fast-compare';
|
||||||
import { Playback, RuntimeStore, SimpleDirection, SimplePlayback, TimerPhase } from 'ontime-types';
|
import { RuntimeStore, runtimeStorePlaceholder } from 'ontime-types';
|
||||||
import { createWithEqualityFn, useStoreWithEqualityFn } from 'zustand/traditional';
|
import { createWithEqualityFn, useStoreWithEqualityFn } from 'zustand/traditional';
|
||||||
|
|
||||||
export const runtimeStorePlaceholder: RuntimeStore = {
|
|
||||||
clock: 0,
|
|
||||||
timer: {
|
|
||||||
addedTime: 0,
|
|
||||||
current: null,
|
|
||||||
duration: null,
|
|
||||||
elapsed: null,
|
|
||||||
expectedFinish: null,
|
|
||||||
finishedAt: null,
|
|
||||||
phase: TimerPhase.None,
|
|
||||||
playback: Playback.Stop,
|
|
||||||
secondaryTimer: null,
|
|
||||||
startedAt: null,
|
|
||||||
},
|
|
||||||
onAir: false,
|
|
||||||
message: {
|
|
||||||
timer: {
|
|
||||||
text: '',
|
|
||||||
visible: false,
|
|
||||||
blink: false,
|
|
||||||
blackout: false,
|
|
||||||
secondarySource: null,
|
|
||||||
},
|
|
||||||
external: '',
|
|
||||||
},
|
|
||||||
runtime: {
|
|
||||||
selectedEventIndex: null,
|
|
||||||
numEvents: 0,
|
|
||||||
offset: 0,
|
|
||||||
plannedStart: 0,
|
|
||||||
plannedEnd: 0,
|
|
||||||
actualStart: null,
|
|
||||||
expectedEnd: null,
|
|
||||||
},
|
|
||||||
currentBlock: {
|
|
||||||
block: null,
|
|
||||||
startedAt: null,
|
|
||||||
},
|
|
||||||
eventNow: null,
|
|
||||||
eventNext: null,
|
|
||||||
publicEventNow: null,
|
|
||||||
publicEventNext: null,
|
|
||||||
auxtimer1: {
|
|
||||||
current: 0,
|
|
||||||
direction: SimpleDirection.CountUp,
|
|
||||||
duration: 0,
|
|
||||||
playback: SimplePlayback.Stop,
|
|
||||||
},
|
|
||||||
frozen: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const deepCompare = <T>(a: T, b: T) => isEqual(a, b);
|
const deepCompare = <T>(a: T, b: T) => isEqual(a, b);
|
||||||
|
|
||||||
export const runtimeStore = createWithEqualityFn<RuntimeStore>(
|
export const runtimeStore = createWithEqualityFn<RuntimeStore>(
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { SimpleDirection, SimplePlayback } from './AuxTimer.type.js';
|
||||||
|
import { Playback } from './Playback.type.js';
|
||||||
|
import type { RuntimeStore } from './RuntimeStore.type.js';
|
||||||
|
import { TimerPhase } from './TimerState.type.js';
|
||||||
|
|
||||||
|
export const runtimeStorePlaceholder: RuntimeStore = {
|
||||||
|
clock: 0,
|
||||||
|
timer: {
|
||||||
|
addedTime: 0,
|
||||||
|
current: null,
|
||||||
|
duration: null,
|
||||||
|
elapsed: null,
|
||||||
|
expectedFinish: null,
|
||||||
|
finishedAt: null,
|
||||||
|
phase: TimerPhase.None,
|
||||||
|
playback: Playback.Stop,
|
||||||
|
secondaryTimer: null,
|
||||||
|
startedAt: null,
|
||||||
|
},
|
||||||
|
onAir: false,
|
||||||
|
message: {
|
||||||
|
timer: {
|
||||||
|
text: '',
|
||||||
|
visible: false,
|
||||||
|
blink: false,
|
||||||
|
blackout: false,
|
||||||
|
secondarySource: null,
|
||||||
|
},
|
||||||
|
external: '',
|
||||||
|
},
|
||||||
|
runtime: {
|
||||||
|
selectedEventIndex: null,
|
||||||
|
numEvents: 0,
|
||||||
|
offset: 0,
|
||||||
|
plannedStart: 0,
|
||||||
|
plannedEnd: 0,
|
||||||
|
actualStart: null,
|
||||||
|
expectedEnd: null,
|
||||||
|
},
|
||||||
|
currentBlock: {
|
||||||
|
block: null,
|
||||||
|
startedAt: null,
|
||||||
|
},
|
||||||
|
eventNow: null,
|
||||||
|
eventNext: null,
|
||||||
|
publicEventNow: null,
|
||||||
|
publicEventNext: null,
|
||||||
|
auxtimer1: {
|
||||||
|
current: 0,
|
||||||
|
direction: SimpleDirection.CountUp,
|
||||||
|
duration: 0,
|
||||||
|
playback: SimplePlayback.Stop,
|
||||||
|
},
|
||||||
|
frozen: false,
|
||||||
|
};
|
||||||
@@ -62,6 +62,7 @@ export type { TimerMessage, MessageState } from './definitions/runtime/MessageCo
|
|||||||
|
|
||||||
export type { Runtime } from './definitions/runtime/Runtime.type.js';
|
export type { Runtime } from './definitions/runtime/Runtime.type.js';
|
||||||
export type { RuntimeStore } from './definitions/runtime/RuntimeStore.type.js';
|
export type { RuntimeStore } from './definitions/runtime/RuntimeStore.type.js';
|
||||||
|
export { runtimeStorePlaceholder } from './definitions/runtime/RuntimeStore.js';
|
||||||
export { type TimerState, TimerPhase } from './definitions/runtime/TimerState.type.js';
|
export { type TimerState, TimerPhase } from './definitions/runtime/TimerState.type.js';
|
||||||
export type { CurrentBlockState } from './definitions/runtime/CurrentBlockState.type.js';
|
export type { CurrentBlockState } from './definitions/runtime/CurrentBlockState.type.js';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user