From 9689f66d2e5dd5922c69b247190b7c011a3dc9ae Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 28 Oct 2020 18:59:17 -0700 Subject: [PATCH] Add config values to home overview --- web/pages/index.tsx | 28 ++++++++++++++++++---------- web/pages/utils/format.ts | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/web/pages/index.tsx b/web/pages/index.tsx index e1c8f9b42..e17a5dbf0 100644 --- a/web/pages/index.tsx +++ b/web/pages/index.tsx @@ -54,12 +54,11 @@ export default function Stats() { // Pull in the server config so we can show config overview. - const [videoSettings, setVideoSettings] = useState([]); + const [config, setConfig] = useState([]); const getConfig = async () => { try { const result = await fetchData(SERVER_CONFIG); - const variants = result && result.videoSettings && result.videoSettings.videoQualityVariants; - setVideoSettings(variants); + setConfig(result); } catch (error) { console.log(error); } @@ -71,7 +70,7 @@ export default function Stats() { getConfig(); }, []); - if (!stats || isEmptyObject(stats)) { + if (isEmptyObject(config) || isEmptyObject(stats)) { return (
@@ -84,7 +83,8 @@ export default function Stats() { if (!broadcaster) { return ; } - + + const videoSettings = config.videoSettings.videoQualityVariants; const videoQualitySettings = videoSettings.map((setting, index) => { const audioSetting = setting.audioPassthrough || setting.audioBitrate === 0 @@ -93,11 +93,6 @@ export default function Stats() { return ( - {videoQualitySettings} + + + + +
); } diff --git a/web/pages/utils/format.ts b/web/pages/utils/format.ts index 43d51d3f0..4f618e16e 100644 --- a/web/pages/utils/format.ts +++ b/web/pages/utils/format.ts @@ -15,5 +15,5 @@ export function formatIPAddress(ipAddress: string): string { // check if obj is {} export function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return !obj || Object.keys(obj).length === 0; }