From 667abb3a55dbe4b77f00ef9d160bc011ba57e668 Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Thu, 20 Oct 2022 03:02:11 -0600 Subject: [PATCH] Personal Server - remove same function on disconnect as added on reconnect. (#4006) * only dispatch initialLoad if me is defined, prevents recalling in loop * update to add/remove same function on reconnect --- webapp/src/pages/boardPage/boardPage.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/src/pages/boardPage/boardPage.tsx b/webapp/src/pages/boardPage/boardPage.tsx index 43c775272..05fcae7e9 100644 --- a/webapp/src/pages/boardPage/boardPage.tsx +++ b/webapp/src/pages/boardPage/boardPage.tsx @@ -141,11 +141,15 @@ const BoardPage = (props: Props): JSX.Element => { } } + const dispatchLoadAction = () => { + dispatch(loadAction(match.params.boardId)) + } + Utils.log('useWEbsocket adding onChange handler') wsClient.addOnChange(incrementalBlockUpdate, 'block') wsClient.addOnChange(incrementalBoardUpdate, 'board') wsClient.addOnChange(incrementalBoardMemberUpdate, 'boardMembers') - wsClient.addOnReconnect(() => dispatch(loadAction(match.params.boardId))) + wsClient.addOnReconnect(dispatchLoadAction) wsClient.setOnFollowBlock((_: WSClient, subscription: Subscription): void => { if (subscription.subscriberId === me?.id) { @@ -163,7 +167,7 @@ const BoardPage = (props: Props): JSX.Element => { wsClient.removeOnChange(incrementalBlockUpdate, 'block') wsClient.removeOnChange(incrementalBoardUpdate, 'board') wsClient.removeOnChange(incrementalBoardMemberUpdate, 'boardMembers') - wsClient.removeOnReconnect(() => dispatch(loadAction(match.params.boardId))) + wsClient.removeOnReconnect(dispatchLoadAction) } }, [me?.id, activeBoardId])