mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 08:53:51 +00:00
refactor: use context rundown in finder
This commit is contained in:
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
||||
import { useRundownSelectionContext } from '../context/RundownSelectionContext';
|
||||
import { useSelectedEventId } from '../hooks/useSocket';
|
||||
import { getFlatRundownMetadata, getRundownMetadata } from '../utils/rundownMetadata';
|
||||
import { useRundown } from './useRundown';
|
||||
import { useFlatRundown, useRundown } from './useRundown';
|
||||
|
||||
export function useContextRundownEditModal() {
|
||||
'use memo';
|
||||
@@ -62,3 +62,18 @@ export function useContextRundownTable() {
|
||||
[flatRundown, status, loadedEventId],
|
||||
);
|
||||
}
|
||||
|
||||
export function useContextRundownFinder() {
|
||||
'use memo';
|
||||
const { effectiveRundownId } = useRundownSelectionContext();
|
||||
const { data: rundown, status } = useFlatRundown(effectiveRundownId);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
rundown,
|
||||
rundownId: effectiveRundownId,
|
||||
status,
|
||||
}),
|
||||
[rundown, status, effectiveRundownId],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EntryId, MaybeString, SupportedEntry, isOntimeEvent, isOntimeGroup, isOntimeMilestone } from 'ontime-types';
|
||||
import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { useFlatRundown } from '../../../common/hooks-query/useRundown';
|
||||
import { useContextRundownFinder } from '../../../common/hooks-query/useContextRundown';
|
||||
import { useSelectAndRevealEntry } from '../../../features/rundown/useSelectAndRevealEntry';
|
||||
|
||||
const maxResults = 12;
|
||||
@@ -38,7 +38,7 @@ type FilterableMilestone = {
|
||||
type FilterableEntry = FilterableGroup | FilterableEvent | FilterableMilestone;
|
||||
|
||||
export default function useFinder() {
|
||||
const { data, rundownId } = useFlatRundown();
|
||||
const { rundown: data, rundownId } = useContextRundownFinder();
|
||||
const [results, setResults] = useState<FilterableEntry[]>([]);
|
||||
const [error, setError] = useState<MaybeString>(null);
|
||||
const lastSearchString = useRef('');
|
||||
|
||||
Reference in New Issue
Block a user