From c1bc72754ac4aab3f2dadbb12125e557d292cf28 Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 6 Jan 2023 09:24:36 -0700 Subject: [PATCH] Displaying placeholders when downloads are being fetched. --- app/src/components/admin/Downloads.js | 6 ++---- app/src/hooks/customHooks.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/components/admin/Downloads.js b/app/src/components/admin/Downloads.js index 36fe95b5..5f237459 100644 --- a/app/src/components/admin/Downloads.js +++ b/app/src/components/admin/Downloads.js @@ -313,8 +313,6 @@ class StoppableRow extends React.Component { export function Downloads() { useTitle('Downloads'); - const {t} = useContext(ThemeContext); - const {onceDownloads, recurringDownloads, fetchDownloads} = useDownloads(); const tablePlaceholder = @@ -345,7 +343,7 @@ export function Downloads() { ); let onceTable = tablePlaceholder; - if (_.isEmpty(onceDownloads)) { + if (onceDownloads && _.isEmpty(onceDownloads)) { onceTable = No downloads are scheduled. } else if (onceDownloads) { onceTable = ( @@ -364,7 +362,7 @@ export function Downloads() { } let recurringTable = tablePlaceholder; - if (_.isEmpty(recurringDownloads)) { + if (recurringDownloads && _.isEmpty(recurringDownloads)) { recurringTable = No recurring downloads are scheduled. } else if (recurringDownloads) { recurringTable = diff --git a/app/src/hooks/customHooks.js b/app/src/hooks/customHooks.js index e2638a95..ad094d6e 100644 --- a/app/src/hooks/customHooks.js +++ b/app/src/hooks/customHooks.js @@ -494,8 +494,8 @@ export const useHotspot = () => { } export const useDownloads = () => { - const [onceDownloads, setOnceDownloads] = useState(); - const [recurringDownloads, setRecurringDownloads] = useState(); + const [onceDownloads, setOnceDownloads] = useState(null); + const [recurringDownloads, setRecurringDownloads] = useState(null); const fetchDownloads = async () => { try {