mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-08 07:49:12 +00:00
fix: undefined flatRundown
This commit is contained in:
committed by
Carlos Valente
parent
d116670318
commit
cd5af769ab
@@ -30,7 +30,15 @@ export default function useRundown() {
|
|||||||
placeholderData: (previousData, _previousQuery) => previousData,
|
placeholderData: (previousData, _previousQuery) => previousData,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
});
|
});
|
||||||
return { data: data ?? cachedRundownPlaceholder, status, isError, refetch, isFetching };
|
|
||||||
|
const returnData = useMemo(() => {
|
||||||
|
if (data && Array.isArray(data.flatOrder)) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
return cachedRundownPlaceholder;
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
|
return { data: returnData, status, isError, refetch, isFetching };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useRundownWithMetadata() {
|
export function useRundownWithMetadata() {
|
||||||
@@ -54,8 +62,10 @@ export function useFlatRundown() {
|
|||||||
|
|
||||||
// update data whenever the revision changes
|
// update data whenever the revision changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data.revision !== -1 || data.revision !== prevRevision) {
|
if (data.revision !== -1 && data.revision !== prevRevision) {
|
||||||
const flatRundown = data.flatOrder.map((id) => data.entries[id]);
|
const flatRundown = data.flatOrder
|
||||||
|
.map((id) => data.entries[id])
|
||||||
|
.filter((entry): entry is OntimeEntry => entry !== undefined);
|
||||||
setFlatRundown(flatRundown);
|
setFlatRundown(flatRundown);
|
||||||
setPrevRevision(data.revision);
|
setPrevRevision(data.revision);
|
||||||
}
|
}
|
||||||
@@ -103,7 +113,7 @@ export function useEntry(entryId: EntryId | null): OntimeEntry | null {
|
|||||||
// track the specific entry we care about
|
// track the specific entry we care about
|
||||||
const entry = useMemo(() => {
|
const entry = useMemo(() => {
|
||||||
if (entryId === null) return null;
|
if (entryId === null) return null;
|
||||||
return rundown.entries[entryId];
|
return rundown.entries[entryId] ?? null;
|
||||||
}, [entryId, rundown.entries]);
|
}, [entryId, rundown.entries]);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user