mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
Remove public event feature (#1645)
This commit is contained in:
committed by
GitHub
parent
4e561cf01f
commit
c522860d28
@@ -1,4 +1,4 @@
|
||||
import { ComponentType, useMemo } from 'react';
|
||||
import { ComponentType } from 'react';
|
||||
import { ViewExtendedTimer } from 'common/models/TimeManager.type';
|
||||
import {
|
||||
CustomFields,
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
Runtime,
|
||||
Settings,
|
||||
SimpleTimerState,
|
||||
SupportedEntry,
|
||||
TimerType,
|
||||
ViewSettings,
|
||||
} from 'ontime-types';
|
||||
@@ -25,19 +24,15 @@ import { useViewOptionsStore } from '../../common/stores/viewOptions';
|
||||
|
||||
type WithDataProps = {
|
||||
auxTimer: SimpleTimerState;
|
||||
backstageEvents: OntimeEvent[];
|
||||
events: OntimeEvent[];
|
||||
customFields: CustomFields;
|
||||
eventNext: OntimeEvent | null;
|
||||
eventNow: OntimeEvent | null;
|
||||
events: OntimeEvent[];
|
||||
general: ProjectData;
|
||||
isMirrored: boolean;
|
||||
message: MessageState;
|
||||
nextId: string | null;
|
||||
onAir: boolean;
|
||||
publicEventNext: OntimeEvent | null;
|
||||
publicEventNow: OntimeEvent | null;
|
||||
publicSelectedId: string | null;
|
||||
runtime: Runtime;
|
||||
selectedId: string | null;
|
||||
settings: Settings | undefined; // TODO: what is the case for this being undefined?
|
||||
@@ -61,17 +56,9 @@ const withData = <P extends WithDataProps>(Component: ComponentType<P>) => {
|
||||
const { data: settings } = useSettings();
|
||||
const { data: customFields } = useCustomFields();
|
||||
|
||||
const publicEvents = useMemo(() => {
|
||||
if (Array.isArray(rundownData)) {
|
||||
return rundownData.filter((e) => e.type === SupportedEntry.Event && e.title && e.isPublic);
|
||||
}
|
||||
return [];
|
||||
}, [rundownData]);
|
||||
|
||||
// websocket data
|
||||
const { clock, timer, message, onAir, eventNext, publicEventNext, publicEventNow, eventNow, runtime, auxtimer1 } =
|
||||
const { clock, timer, message, onAir, eventNext, eventNow, runtime, auxtimer1 } =
|
||||
useStore(runtimeStore);
|
||||
const publicSelectedId = publicEventNow?.id ?? null;
|
||||
const selectedId = eventNow?.id ?? null;
|
||||
const nextId = eventNext?.id ?? null;
|
||||
|
||||
@@ -91,19 +78,15 @@ const withData = <P extends WithDataProps>(Component: ComponentType<P>) => {
|
||||
<Component
|
||||
{...props}
|
||||
auxTimer={auxtimer1}
|
||||
backstageEvents={rundownData}
|
||||
events={rundownData}
|
||||
customFields={customFields}
|
||||
eventNext={eventNext}
|
||||
eventNow={eventNow}
|
||||
events={publicEvents}
|
||||
general={project}
|
||||
isMirrored={isMirrored}
|
||||
message={message}
|
||||
nextId={nextId}
|
||||
onAir={onAir}
|
||||
publicEventNext={publicEventNext}
|
||||
publicEventNow={publicEventNow}
|
||||
publicSelectedId={publicSelectedId}
|
||||
runtime={runtime}
|
||||
selectedId={selectedId}
|
||||
settings={settings}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
ProjectData,
|
||||
Runtime,
|
||||
Settings,
|
||||
SupportedEntry,
|
||||
TimerPhase,
|
||||
} from 'ontime-types';
|
||||
|
||||
@@ -27,7 +26,7 @@ import CountdownSelect from './CountdownSelect';
|
||||
import './Countdown.scss';
|
||||
|
||||
interface CountdownProps {
|
||||
backstageEvents: OntimeEvent[];
|
||||
events: OntimeEvent[];
|
||||
general: ProjectData;
|
||||
isMirrored: boolean;
|
||||
runtime: Runtime;
|
||||
@@ -37,7 +36,7 @@ interface CountdownProps {
|
||||
}
|
||||
|
||||
export default function Countdown(props: CountdownProps) {
|
||||
const { backstageEvents, general, isMirrored, runtime, selectedId, settings, time } = props;
|
||||
const { events, general, isMirrored, runtime, selectedId, settings, time } = props;
|
||||
const [searchParams] = useSearchParams();
|
||||
const { getLocalizedString } = useTranslation();
|
||||
|
||||
@@ -49,7 +48,7 @@ export default function Countdown(props: CountdownProps) {
|
||||
// eg. http://localhost:4001/countdown?eventId=ei0us
|
||||
// update data to the event we are following
|
||||
useEffect(() => {
|
||||
if (!backstageEvents) {
|
||||
if (!events) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +62,6 @@ export default function Countdown(props: CountdownProps) {
|
||||
}
|
||||
|
||||
let followThis: OntimeEvent | null = null;
|
||||
const events: OntimeEvent[] = [...backstageEvents].filter((event) => event.type === SupportedEntry.Event);
|
||||
|
||||
if (eventId !== null) {
|
||||
followThis = events.find((event) => event.id === eventId) || null;
|
||||
@@ -72,11 +70,11 @@ export default function Countdown(props: CountdownProps) {
|
||||
}
|
||||
if (followThis !== null) {
|
||||
setFollow(followThis);
|
||||
const idx: number = backstageEvents.findIndex((event: OntimeEntry) => event.id === followThis?.id);
|
||||
const delayToEvent = backstageEvents[idx]?.delay ?? 0;
|
||||
const idx: number = events.findIndex((event: OntimeEntry) => event.id === followThis?.id);
|
||||
const delayToEvent = events[idx]?.delay ?? 0;
|
||||
setDelay(delayToEvent);
|
||||
}
|
||||
}, [backstageEvents, searchParams]);
|
||||
}, [events, searchParams]);
|
||||
|
||||
const { message: runningMessage, timer: runningTimer } = fetchTimerData(time, follow, selectedId, runtime.offset);
|
||||
|
||||
@@ -119,7 +117,7 @@ export default function Countdown(props: CountdownProps) {
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
<ViewParamsEditor viewOptions={viewOptions} />
|
||||
{follow === null ? (
|
||||
<CountdownSelect events={backstageEvents} />
|
||||
<CountdownSelect events={events} />
|
||||
) : (
|
||||
<div className='countdown-container' data-testid='countdown-event'>
|
||||
<div className='clock-container'>
|
||||
|
||||
+24
-22
@@ -1,3 +1,5 @@
|
||||
import { ViewExtendedTimer } from 'common/models/TimeManager.type';
|
||||
import { OntimeEvent } from 'ontime-types';
|
||||
import { dayInMs } from 'ontime-utils';
|
||||
|
||||
import { fetchTimerData, sanitiseTitle, TimerMessage } from '../countdown.helpers';
|
||||
@@ -14,7 +16,7 @@ describe('sanitiseTitle() function', () => {
|
||||
it('should return {no title} when invalid', () => {
|
||||
const invalidTitles = ['', undefined, null];
|
||||
for (const title of invalidTitles) {
|
||||
expect(sanitiseTitle(title)).toBe('{no title}');
|
||||
expect(sanitiseTitle(title as unknown as string)).toBe('{no title}');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -23,10 +25,10 @@ describe('fetchTimerData() function', () => {
|
||||
it('shows current timer if current is the one we follow', () => {
|
||||
const followId = 'testId';
|
||||
const currentMockValue = 13;
|
||||
const follow = { id: followId };
|
||||
const time = { current: currentMockValue };
|
||||
const follow = { id: followId } as OntimeEvent;
|
||||
const time = { current: currentMockValue } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, followId);
|
||||
const { message, timer } = fetchTimerData(time, follow, followId, 0);
|
||||
expect(message).toBe(TimerMessage.running);
|
||||
expect(timer).toBe(currentMockValue);
|
||||
});
|
||||
@@ -34,10 +36,10 @@ describe('fetchTimerData() function', () => {
|
||||
it('shows the countdown to an upcoming event', () => {
|
||||
const startMockValue = 10000;
|
||||
const timeNow = 1000;
|
||||
const follow = { id: 'anotherevent', timeStart: startMockValue };
|
||||
const time = { clock: timeNow };
|
||||
const follow = { id: 'anotherevent', timeStart: startMockValue } as OntimeEvent;
|
||||
const time = { clock: timeNow } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent');
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent', 0);
|
||||
expect(message).toBe(TimerMessage.toStart);
|
||||
expect(timer).toBe(startMockValue - timeNow);
|
||||
});
|
||||
@@ -47,10 +49,10 @@ describe('fetchTimerData() function', () => {
|
||||
const endMockValue = 20000;
|
||||
const timeNow = 15000;
|
||||
const followId = 'testId';
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue };
|
||||
const time = { clock: timeNow, current: endMockValue - startMockValue };
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue } as OntimeEvent;
|
||||
const time = { clock: timeNow, current: endMockValue - startMockValue } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent');
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent', 0);
|
||||
expect(message).toBe(TimerMessage.waiting);
|
||||
expect(timer).toBe(endMockValue - startMockValue);
|
||||
});
|
||||
@@ -60,10 +62,10 @@ describe('fetchTimerData() function', () => {
|
||||
const endMockValue = 20000;
|
||||
const timeNow = 30000;
|
||||
const followId = 'testId';
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue };
|
||||
const time = { clock: timeNow, current: endMockValue - startMockValue };
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue } as OntimeEvent;
|
||||
const time = { clock: timeNow, current: endMockValue - startMockValue } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent');
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent', 0);
|
||||
expect(message).toBe(TimerMessage.ended);
|
||||
expect(timer).toBe(endMockValue);
|
||||
});
|
||||
@@ -73,10 +75,10 @@ describe('fetchTimerData() function', () => {
|
||||
const endMockValue = 1000;
|
||||
const timeNow = 15000;
|
||||
const followId = 'testId';
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue };
|
||||
const time = { clock: timeNow, current: dayInMs + endMockValue - startMockValue };
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue } as OntimeEvent;
|
||||
const time = { clock: timeNow, current: dayInMs + endMockValue - startMockValue } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent');
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent', 0);
|
||||
expect(message).toBe(TimerMessage.waiting);
|
||||
expect(timer).toBe(dayInMs + endMockValue - startMockValue);
|
||||
});
|
||||
@@ -86,10 +88,10 @@ describe('fetchTimerData() function', () => {
|
||||
const endMockValue = 1000;
|
||||
const timeNow = 15000;
|
||||
const followId = 'testId';
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue };
|
||||
const time = { clock: timeNow, current: dayInMs + endMockValue - startMockValue };
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue } as OntimeEvent;
|
||||
const time = { clock: timeNow, current: dayInMs + endMockValue - startMockValue } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, followId);
|
||||
const { message, timer } = fetchTimerData(time, follow, followId, 0);
|
||||
expect(message).toBe(TimerMessage.running);
|
||||
expect(timer).toBe(dayInMs + endMockValue - startMockValue);
|
||||
});
|
||||
@@ -99,10 +101,10 @@ describe('fetchTimerData() function', () => {
|
||||
const endMockValue = 1000;
|
||||
const timeNow = 2000;
|
||||
const followId = 'testId';
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue };
|
||||
const time = { clock: timeNow, current: dayInMs + endMockValue - startMockValue };
|
||||
const follow = { id: followId, timeStart: startMockValue, timeEnd: endMockValue } as OntimeEvent;
|
||||
const time = { clock: timeNow, current: dayInMs + endMockValue - startMockValue } as ViewExtendedTimer;
|
||||
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent');
|
||||
const { message, timer } = fetchTimerData(time, follow, 'notthesameevent', 0);
|
||||
expect(message).toBe(TimerMessage.toStart);
|
||||
expect(timer).toBe(startMockValue - timeNow);
|
||||
});
|
||||
@@ -26,7 +26,7 @@ export default function LowerThird(props: LowerProps) {
|
||||
const animationTimeout = useRef<NodeJS.Timeout>();
|
||||
const [playState, setPlayState] = useState<boolean>(false);
|
||||
const [textValue, setTextValue] = useState<{ top: string; bottom: string }>({ top: '', bottom: '' });
|
||||
useRuntimeStylesheet(viewSettings?.overrideStyles && overrideStylesURL);
|
||||
useRuntimeStylesheet(viewSettings?.overrideStyles ? overrideStylesURL : undefined);
|
||||
const options = useLowerOptions();
|
||||
const { playback } = time;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import StudioClockSchedule from './StudioClockSchedule';
|
||||
import './StudioClock.scss';
|
||||
|
||||
interface StudioClockProps {
|
||||
backstageEvents: OntimeEntry[];
|
||||
events: OntimeEntry[];
|
||||
eventNext: OntimeEvent | null;
|
||||
general: ProjectData;
|
||||
isMirrored: boolean;
|
||||
@@ -29,7 +29,7 @@ interface StudioClockProps {
|
||||
}
|
||||
|
||||
export default function StudioClock(props: StudioClockProps) {
|
||||
const { backstageEvents, eventNext, general, isMirrored, time, selectedId, nextId, onAir, settings } = props;
|
||||
const { events, eventNext, general, isMirrored, time, selectedId, nextId, onAir, settings } = props;
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
@@ -102,7 +102,7 @@ export default function StudioClock(props: StudioClockProps) {
|
||||
</div>
|
||||
</div>
|
||||
{!hideRight && (
|
||||
<StudioClockSchedule rundown={backstageEvents} selectedId={selectedId} nextId={nextId} onAir={onAir} />
|
||||
<StudioClockSchedule rundown={events} selectedId={selectedId} nextId={nextId} onAir={onAir} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user