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