From 32ac0fadc4bd3f3c31dbc42de573c4d93d923409 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Thu, 20 Oct 2022 17:37:58 +0200 Subject: [PATCH] improve loading --- .../app/src/pages/home/components/livestreams/index.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/app/src/pages/home/components/livestreams/index.jsx b/packages/app/src/pages/home/components/livestreams/index.jsx index feda82e0..8721deb6 100644 --- a/packages/app/src/pages/home/components/livestreams/index.jsx +++ b/packages/app/src/pages/home/components/livestreams/index.jsx @@ -35,9 +35,12 @@ const LivestreamItem = (props) => { } export default (props) => { + const [loading, setLoading] = React.useState(true) const [list, setList] = React.useState([]) const loadStreamings = async () => { + setLoading(true) + const livestreams = await Livestream.getLivestreams().catch((err) => { console.error(err) app.message.error("Failed to load livestreams") @@ -46,6 +49,8 @@ export default (props) => { console.log("Livestreams", livestreams) + setLoading(false) + if (livestreams) { if (!Array.isArray(livestreams)) { console.error("Livestreams is not an array") @@ -65,6 +70,10 @@ export default (props) => { } const renderList = () => { + if (loading) { + return + } + if (list.length === 0) { return