From c14f1b560873315401897ea2b3dc65931bac5012 Mon Sep 17 00:00:00 2001 From: Gabriel Dutra Date: Tue, 29 Oct 2019 22:35:00 -0300 Subject: [PATCH 1/2] Skip favorites dropdown loading state on init --- .../app-header/components/FavoritesDropdown.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/app/components/app-header/components/FavoritesDropdown.jsx b/client/app/components/app-header/components/FavoritesDropdown.jsx index 5155decde7..7d3bcca238 100644 --- a/client/app/components/app-header/components/FavoritesDropdown.jsx +++ b/client/app/components/app-header/components/FavoritesDropdown.jsx @@ -15,8 +15,10 @@ export default function FavoritesDropdown({ fetch, urlTemplate }) { const noItems = isEmpty(items); const urlCompiled = useMemo(() => template(urlTemplate), [urlTemplate]); - const fetchItems = useCallback(() => { - setLoading(true); + const fetchItems = useCallback((skipLoadingState = false) => { + if (!skipLoadingState) { + setLoading(true); + } fetch().$promise .then(({ results }) => { setItems(results); @@ -27,7 +29,7 @@ export default function FavoritesDropdown({ fetch, urlTemplate }) { }, [fetch]); // fetch items on init - useEffect(fetchItems, []); + useEffect(() => fetchItems(true), []); // fetch items on click const onVisibleChange = visible => visible && fetchItems(); From 0b06f55d8124f82f29242e890196bf4c4d7f4fda Mon Sep 17 00:00:00 2001 From: Gabriel Dutra Date: Thu, 31 Oct 2019 10:01:45 -0300 Subject: [PATCH 2/2] skipLoadingState -> showLoadingState --- .../app-header/components/FavoritesDropdown.jsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/app/components/app-header/components/FavoritesDropdown.jsx b/client/app/components/app-header/components/FavoritesDropdown.jsx index 7d3bcca238..d21642792c 100644 --- a/client/app/components/app-header/components/FavoritesDropdown.jsx +++ b/client/app/components/app-header/components/FavoritesDropdown.jsx @@ -15,10 +15,8 @@ export default function FavoritesDropdown({ fetch, urlTemplate }) { const noItems = isEmpty(items); const urlCompiled = useMemo(() => template(urlTemplate), [urlTemplate]); - const fetchItems = useCallback((skipLoadingState = false) => { - if (!skipLoadingState) { - setLoading(true); - } + const fetchItems = useCallback((showLoadingState = true) => { + setLoading(showLoadingState); fetch().$promise .then(({ results }) => { setItems(results); @@ -29,7 +27,7 @@ export default function FavoritesDropdown({ fetch, urlTemplate }) { }, [fetch]); // fetch items on init - useEffect(() => fetchItems(true), []); + useEffect(() => fetchItems(false), []); // fetch items on click const onVisibleChange = visible => visible && fetchItems();