From 4dc3b7768930f80351715e6e9c06684b31c09a91 Mon Sep 17 00:00:00 2001 From: caneppelevitor Date: Mon, 25 Nov 2024 21:03:51 +0100 Subject: [PATCH] fix: Correctly manage loading state for fetching results --- src/components/Search/OverlaySearchInput.tsx | 3 ++- src/store/actions.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Search/OverlaySearchInput.tsx b/src/components/Search/OverlaySearchInput.tsx index 9e0ca1bf7..41ea47336 100644 --- a/src/components/Search/OverlaySearchInput.tsx +++ b/src/components/Search/OverlaySearchInput.tsx @@ -23,7 +23,7 @@ const OverlaySearchInput = () => { }); const handleInputSearch = async (name) => { - dispatch(actions.isFetchingResults()); + dispatch(actions.setResultsLoading(true)); dispatch(actions.openResultsOverlay()); dispatch({ type: ActionTypes.SET_SEARCH_OVERLAY_NAME, @@ -38,6 +38,7 @@ const OverlaySearchInput = () => { nameSpace: nameSpace, }); + dispatch(actions.setResultsLoading(false)); dispatch(actions.openResultsOverlay()); dispatch({ type: ActionTypes.SEARCH_OVERLAY_RESULTS, diff --git a/src/store/actions.ts b/src/store/actions.ts index 857f2e7e8..207c61138 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -2,9 +2,9 @@ import { Content } from "../types/Content"; import { ActionTypes } from "./types"; const actions = { - isFetchingResults: () => ({ + setResultsLoading: (isFetching) => ({ type: ActionTypes.RESULTS_LOADING, - isFetching: true, + isFetching, }), openResultsOverlay: () => ({ type: ActionTypes.RESULTS_OVERLAY_VISIBLE,