Skip to content

Commit

Permalink
fix: Correctly manage loading state for fetching results
Browse files Browse the repository at this point in the history
  • Loading branch information
caneppelevitor committed Nov 25, 2024
1 parent 46b49a2 commit 4dc3b77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/Search/OverlaySearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -38,6 +38,7 @@ const OverlaySearchInput = () => {
nameSpace: nameSpace,
});

dispatch(actions.setResultsLoading(false));
dispatch(actions.openResultsOverlay());
dispatch({
type: ActionTypes.SEARCH_OVERLAY_RESULTS,
Expand Down
4 changes: 2 additions & 2 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4dc3b77

Please sign in to comment.