Skip to content

Commit

Permalink
Fixed search pending state
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed May 26, 2024
1 parent 6d7cb09 commit 798a71f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/search1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,14 @@ export const createSearch1AutocompleteStore = (
params.set('user', options.user);
}

let shouldLoad = true;

if ((!query || query.length < 3) && !options.motivation && !options.date && !options.user) {
set({ results: [], loading: false, lastQuery: null });
return;
shouldLoad = false;
}

set({
loading: true,
loading: shouldLoad,
lastQuery: {
q: query,
motivation: options.motivation,
Expand All @@ -137,6 +138,10 @@ export const createSearch1AutocompleteStore = (
},
});

if (!shouldLoad) {
return;
}

return fetcher(`${endpoint}?${params.toString()}`, {
signal: abort.signal,
headers: {
Expand Down

0 comments on commit 798a71f

Please sign in to comment.