diff --git a/ui/component/livestreamComments/index.js b/ui/component/livestreamComments/index.js index b0f6e029b..3c7b7a862 100644 --- a/ui/component/livestreamComments/index.js +++ b/ui/component/livestreamComments/index.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { makeSelectClaimForUri } from 'lbry-redux'; -import { doCommentSocketConnect } from 'redux/actions/websocket'; +import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket'; import { doCommentList } from 'redux/actions/comments'; import { makeSelectTopLevelCommentsForUri, selectIsFetchingComments } from 'redux/selectors/comments'; import LivestreamFeed from './view'; @@ -11,4 +11,4 @@ const select = (state, props) => ({ fetchingComments: selectIsFetchingComments(state), }); -export default connect(select, { doCommentSocketConnect, doCommentList })(LivestreamFeed); +export default connect(select, { doCommentSocketConnect, doCommentSocketDisconnect, doCommentList })(LivestreamFeed); diff --git a/ui/component/livestreamComments/view.jsx b/ui/component/livestreamComments/view.jsx index 33305e34e..7b94dea23 100644 --- a/ui/component/livestreamComments/view.jsx +++ b/ui/component/livestreamComments/view.jsx @@ -13,13 +13,23 @@ type Props = { activeViewers: number, embed?: boolean, doCommentSocketConnect: (string, string) => void, + doCommentSocketDisconnect: (string) => void, doCommentList: (string) => void, comments: Array, fetchingComments: boolean, }; export default function LivestreamFeed(props: Props) { - const { claim, uri, embed, doCommentSocketConnect, comments, doCommentList, fetchingComments } = props; + const { + claim, + uri, + embed, + doCommentSocketConnect, + doCommentSocketDisconnect, + comments, + doCommentList, + fetchingComments, + } = props; const commentsRef = React.createRef(); const hasScrolledComments = React.useRef(); const [performedInitialScroll, setPerformedInitialScroll] = React.useState(false); @@ -31,7 +41,13 @@ export default function LivestreamFeed(props: Props) { doCommentList(uri); doCommentSocketConnect(uri, claimId); } - }, [claimId, uri]); + + return () => { + if (claimId) { + doCommentSocketDisconnect(claimId); + } + }; + }, [claimId, uri, doCommentList, doCommentSocketConnect, doCommentSocketDisconnect]); React.useEffect(() => { const element = commentsRef.current; diff --git a/ui/component/livestreamLayout/view.jsx b/ui/component/livestreamLayout/view.jsx index 405a236d4..615de675b 100644 --- a/ui/component/livestreamLayout/view.jsx +++ b/ui/component/livestreamLayout/view.jsx @@ -1,5 +1,5 @@ // @flow -import { BITWAVE_EMBED_URL } from 'constants/livestream'; +// import { BITWAVE_EMBED_URL } from 'constants/livestream'; import React from 'react'; import FileTitleSection from 'component/fileTitleSection'; import LivestreamComments from 'component/livestreamComments'; @@ -22,7 +22,7 @@ export default function LivestreamLayout(props: Props) {
-