From 81065fda6ab646f079e77a8343dd69d9a52b9d36 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 19 Aug 2020 18:11:40 -0700 Subject: [PATCH] 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. --- src/app/WardrobePage/SearchPanel.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/WardrobePage/SearchPanel.js b/src/app/WardrobePage/SearchPanel.js index d702f75..b1eb8df 100644 --- a/src/app/WardrobePage/SearchPanel.js +++ b/src/app/WardrobePage/SearchPanel.js @@ -273,15 +273,16 @@ function useSearchResults(query, outfitState) { // Okay, what kind of loading state is this? let loading; let loadingMore; - if ((loadingGQL && items.length === 0) || resultQuery !== query) { - // If it's our first run, or the first run _since the query changed_, we're - // `loading`. - loading = true; - loadingMore = false; - } else if (loadingGQL) { - // Or, if we're loading GQL but it's not our first run, we're `loadingMore`. + if (loadingGQL && items.length > 0 && resultQuery === query) { + // If we already have items for this query, but we're also loading GQL, + // then we're `loadingMore`. loading = false; 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 { // Otherwise, we're not loading at all! loading = false;