add long polling to reset component
This commit is contained in:
parent
1d8753e2ba
commit
baa15d0c42
1 changed files with 8 additions and 1 deletions
|
@ -4,6 +4,7 @@ import React from 'react';
|
||||||
import { SITE_HELP_EMAIL } from 'config';
|
import { SITE_HELP_EMAIL } from 'config';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import { killStream } from '$web/src/livestreaming';
|
import { killStream } from '$web/src/livestreaming';
|
||||||
|
import watchLivestreamStatus from '$web/src/livestreaming/long-polling';
|
||||||
import 'scss/component/claim-preview-reset.scss';
|
import 'scss/component/claim-preview-reset.scss';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -16,7 +17,13 @@ type Props = {
|
||||||
const ClaimPreviewReset = (props: Props) => {
|
const ClaimPreviewReset = (props: Props) => {
|
||||||
const { channelId, channelName, claimIsMine, doToast } = 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 () => {
|
const handleClick = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue