From baa15d0c422a9eb59aef217faea9557a31d53212 Mon Sep 17 00:00:00 2001 From: Dan Peterson Date: Tue, 9 Nov 2021 12:02:34 -0600 Subject: [PATCH] add long polling to reset component --- ui/component/claimPreviewReset/view.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/component/claimPreviewReset/view.jsx b/ui/component/claimPreviewReset/view.jsx index 37bdb6a76..4c4d1e071 100644 --- a/ui/component/claimPreviewReset/view.jsx +++ b/ui/component/claimPreviewReset/view.jsx @@ -4,6 +4,7 @@ import React from 'react'; import { SITE_HELP_EMAIL } from 'config'; import Button from 'component/button'; import { killStream } from '$web/src/livestreaming'; +import watchLivestreamStatus from '$web/src/livestreaming/long-polling'; import 'scss/component/claim-preview-reset.scss'; type Props = { @@ -16,7 +17,13 @@ type Props = { const ClaimPreviewReset = (props: Props) => { const { channelId, channelName, claimIsMine, doToast } = props; - if (!claimIsMine) return null; + const [isLivestreaming, setIsLivestreaming] = React.useState(false); + + React.useEffect(() => { + return watchLivestreamStatus(channelId, (state) => setIsLivestreaming(state)); + }, [channelId, setIsLivestreaming]); + + if (!claimIsMine || !isLivestreaming) return null; const handleClick = async () => { try {