add long polling to reset component

This commit is contained in:
Dan Peterson 2021-11-09 12:02:34 -06:00 committed by infinite-persistence
parent 1d8753e2ba
commit baa15d0c42
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -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 {