From 9298bf1e51d01724916a9a79d67ef8cfad563e33 Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 15 Mar 2022 15:21:32 -0300 Subject: [PATCH] flow --- ui/effects/use-socket-connect.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/effects/use-socket-connect.js b/ui/effects/use-socket-connect.js index caf9f988b..22e90e3cf 100644 --- a/ui/effects/use-socket-connect.js +++ b/ui/effects/use-socket-connect.js @@ -4,11 +4,11 @@ import { formatLbryChannelName } from 'util/url'; export default function useSocketConnect( isLivestreamClaim: boolean, - claimId: boolean, + claimId: ?string, channelUrl: ?string, - canonicalUrl: boolean, - doCommentSocketConnect: (string, string, string) => void, - doCommentSocketDisconnect: (string, string) => void + canonicalUrl: ?string, + doCommentSocketConnect: (canonicalUrl: string, channelName: string, claimId: string) => void, + doCommentSocketDisconnect: (claimId: string, string) => void ) { // Establish web socket connection for viewer count. React.useEffect(() => { @@ -18,6 +18,10 @@ export default function useSocketConnect( doCommentSocketConnect(canonicalUrl, channelName, claimId); - return () => doCommentSocketDisconnect(claimId, channelName); + return () => { + if (claimId) { + doCommentSocketDisconnect(claimId, channelName); + } + }; }, [canonicalUrl, channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, isLivestreamClaim]); }