improve loading

This commit is contained in:
srgooglo 2022-10-20 17:37:58 +02:00
parent dfe8966d9d
commit 32ac0fadc4

View File

@ -35,9 +35,12 @@ const LivestreamItem = (props) => {
} }
export default (props) => { export default (props) => {
const [loading, setLoading] = React.useState(true)
const [list, setList] = React.useState([]) const [list, setList] = React.useState([])
const loadStreamings = async () => { const loadStreamings = async () => {
setLoading(true)
const livestreams = await Livestream.getLivestreams().catch((err) => { const livestreams = await Livestream.getLivestreams().catch((err) => {
console.error(err) console.error(err)
app.message.error("Failed to load livestreams") app.message.error("Failed to load livestreams")
@ -46,6 +49,8 @@ export default (props) => {
console.log("Livestreams", livestreams) console.log("Livestreams", livestreams)
setLoading(false)
if (livestreams) { if (livestreams) {
if (!Array.isArray(livestreams)) { if (!Array.isArray(livestreams)) {
console.error("Livestreams is not an array") console.error("Livestreams is not an array")
@ -65,6 +70,10 @@ export default (props) => {
} }
const renderList = () => { const renderList = () => {
if (loading) {
return <antd.Skeleton active />
}
if (list.length === 0) { if (list.length === 0) {
return <antd.Result> return <antd.Result>
<h1> <h1>