Skip to content

Commit

Permalink
initialize upon load
Browse files Browse the repository at this point in the history
  • Loading branch information
clairelin135 committed Mar 12, 2024
1 parent c59bf68 commit e30c186
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type State = {
searching: boolean;
secondaryResults: Fuse.FuseResult<SearchResult>[];
highlight: number;
loaded: boolean;
};

type Action =
Expand Down Expand Up @@ -48,7 +47,6 @@ const initialState: State = {
searching: false,
secondaryResults: [],
highlight: 0,
loaded: false,
};

const DEBOUNCE_MSEC = 100;
Expand All @@ -69,7 +67,7 @@ function groupSearchResults(secondaryResults: Fuse.FuseResult<SearchResult>[]):

export const AssetSearch = () => {
const history = useHistory();
const {loading, searchSecondary} = useGlobalSearch({
const {loading, searchSecondary, initialize} = useGlobalSearch({
includeAssetFilters: true,
});

Expand All @@ -88,10 +86,11 @@ export const AssetSearch = () => {
const firstSearchTrace = React.useRef<null | Trace>(null);

React.useEffect(() => {
initialize();
if (!loading && secondaryResults) {
firstSearchTrace.current?.endTrace();
}
}, [loading, secondaryResults]);
}, [loading, secondaryResults, initialize]);

const searchAndHandleSecondary = React.useCallback(
async (queryString: string) => {
Expand Down

0 comments on commit e30c186

Please sign in to comment.