From bb3a75fb2ebe7b75806654aeb01518df4ccfdea1 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Tue, 14 Sep 2021 16:14:57 +0200 Subject: [PATCH] fix: setLoaded after the fetch so state doesnt toggle back and forth --- src/pages/view/ViewDashboard.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/pages/view/ViewDashboard.js b/src/pages/view/ViewDashboard.js index aba10c8ff..5e157b46f 100644 --- a/src/pages/view/ViewDashboard.js +++ b/src/pages/view/ViewDashboard.js @@ -33,7 +33,7 @@ const ViewDashboard = props => { const [loaded, setLoaded] = useState(false) const [loadFailed, setLoadFailed] = useState(false) const { online } = useOnlineStatus() - const { isCached, recordingState } = useCacheableSection(props.requestedId) + const { isCached } = useCacheableSection(props.requestedId) useEffect(() => { setHeaderbarVisible(true) @@ -76,9 +76,8 @@ const ViewDashboard = props => { }, 500) try { - setLoaded(true) await props.fetchDashboard(props.requestedId, props.username) - + setLoaded(true) setLoadFailed(false) setLoadingMessage(null) clearTimeout(alertTimeout) @@ -93,16 +92,14 @@ const ViewDashboard = props => { const requestedIsAvailable = online || isCached const switchingDashboard = props.requestedId !== props.currentId - if ( - requestedIsAvailable && - (recordingState === 'recording' || !loaded) - ) { + + if (requestedIsAvailable && !loaded) { loadDashboard() } else if (!requestedIsAvailable && switchingDashboard) { setLoaded(false) props.setSelectedAsOffline(props.requestedId, props.username) } - }, [props.requestedId, props.currentId, loaded, recordingState, online]) + }, [props.requestedId, props.currentId, loaded, online]) const onExpandedChanged = expanded => setControlbarExpanded(expanded)