fix bug where search error states are hidden

Oops, our loading state logic was eating the error case! I'm not sure exactly where the gap was happening, but I've rewritten the states to be a bit more foolproof, since that first condition was confusing I think.
This commit is contained in:
Emi Matchu 2020-08-19 18:11:40 -07:00
parent f6c228b17e
commit 81065fda6a

View file

@ -273,15 +273,16 @@ function useSearchResults(query, outfitState) {
// Okay, what kind of loading state is this? // Okay, what kind of loading state is this?
let loading; let loading;
let loadingMore; let loadingMore;
if ((loadingGQL && items.length === 0) || resultQuery !== query) { if (loadingGQL && items.length > 0 && resultQuery === query) {
// If it's our first run, or the first run _since the query changed_, we're // If we already have items for this query, but we're also loading GQL,
// `loading`. // then we're `loadingMore`.
loading = true;
loadingMore = false;
} else if (loadingGQL) {
// Or, if we're loading GQL but it's not our first run, we're `loadingMore`.
loading = false; loading = false;
loadingMore = true; loadingMore = true;
} else if (loadingGQL || query !== debouncedQuery) {
// Otherwise, if we're loading GQL or the user has changed the query, we're
// just `loading`.
loading = true;
loadingMore = false;
} else { } else {
// Otherwise, we're not loading at all! // Otherwise, we're not loading at all!
loading = false; loading = false;