flow
This commit is contained in:
parent
ebfe644cb8
commit
9298bf1e51
1 changed files with 9 additions and 5 deletions
|
@ -4,11 +4,11 @@ import { formatLbryChannelName } from 'util/url';
|
||||||
|
|
||||||
export default function useSocketConnect(
|
export default function useSocketConnect(
|
||||||
isLivestreamClaim: boolean,
|
isLivestreamClaim: boolean,
|
||||||
claimId: boolean,
|
claimId: ?string,
|
||||||
channelUrl: ?string,
|
channelUrl: ?string,
|
||||||
canonicalUrl: boolean,
|
canonicalUrl: ?string,
|
||||||
doCommentSocketConnect: (string, string, string) => void,
|
doCommentSocketConnect: (canonicalUrl: string, channelName: string, claimId: string) => void,
|
||||||
doCommentSocketDisconnect: (string, string) => void
|
doCommentSocketDisconnect: (claimId: string, string) => void
|
||||||
) {
|
) {
|
||||||
// Establish web socket connection for viewer count.
|
// Establish web socket connection for viewer count.
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
@ -18,6 +18,10 @@ export default function useSocketConnect(
|
||||||
|
|
||||||
doCommentSocketConnect(canonicalUrl, channelName, claimId);
|
doCommentSocketConnect(canonicalUrl, channelName, claimId);
|
||||||
|
|
||||||
return () => doCommentSocketDisconnect(claimId, channelName);
|
return () => {
|
||||||
|
if (claimId) {
|
||||||
|
doCommentSocketDisconnect(claimId, channelName);
|
||||||
|
}
|
||||||
|
};
|
||||||
}, [canonicalUrl, channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, isLivestreamClaim]);
|
}, [canonicalUrl, channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, isLivestreamClaim]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue