mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 15:09:10 +00:00
refactor: improve performance in rundown
- leverage compiler - correct subscriptions from zustand
This commit is contained in:
committed by
Carlos Valente
parent
0de55e74a8
commit
8e32314667
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import {
|
||||
isOntimeDelay,
|
||||
isOntimeEvent,
|
||||
@@ -24,27 +24,22 @@ export default function RundownEntryEditor() {
|
||||
const selectedEvents = useEventSelection((state) => state.selectedEvents);
|
||||
const { data } = useRundown();
|
||||
|
||||
const [entry, setEntry] = useState<OntimeEvent | OntimeGroup | OntimeMilestone | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const entry = useMemo<OntimeEvent | OntimeGroup | OntimeMilestone | null>(() => {
|
||||
if (data.order.length === 0) {
|
||||
setEntry(null);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const selectedEventId = Array.from(selectedEvents).at(0);
|
||||
if (!selectedEventId) {
|
||||
setEntry(null);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
const event = data.entries[selectedEventId];
|
||||
|
||||
if (event && !isOntimeDelay(event)) {
|
||||
setEntry(event);
|
||||
} else {
|
||||
setEntry(null);
|
||||
return event;
|
||||
}
|
||||
}, [data.order, data.entries, selectedEvents]);
|
||||
return null;
|
||||
}, [data.order.length, data.entries, selectedEvents]);
|
||||
|
||||
if (!entry) {
|
||||
return <EventEditorEmpty />;
|
||||
|
||||
Reference in New Issue
Block a user