From 711da0409f28ad93a9742af76428890a7a4a16af Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Mon, 4 Oct 2021 18:01:49 +0200 Subject: [PATCH] Disable websockets in shared boards (#1391) * Disable websockets in shared boards * Address review comments * Fix linter --- webapp/src/app.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/webapp/src/app.tsx b/webapp/src/app.tsx index 79f50b85d..60badcdde 100644 --- a/webapp/src/app.tsx +++ b/webapp/src/app.tsx @@ -81,6 +81,13 @@ const App = React.memo((): JSX.Element => { const me = useAppSelector(getMe) const dispatch = useAppDispatch() + // this is a temporary solution while we're using legacy routes + // for shared boards as a way to disable websockets, and should be + // removed when anonymous plugin routes are implemented. This + // check is used to detect if we're running inside the plugin but + // in a legacy route + const inPluginLegacy = window.location.pathname.includes('/plugins/focalboard/') + useEffect(() => { dispatch(fetchLanguage()) dispatch(fetchMe()) @@ -88,12 +95,14 @@ const App = React.memo((): JSX.Element => { history.replace(window.location.pathname.replace((window as any).frontendBaseURL, '')) }, []) - useEffect(() => { - wsClient.open() - return () => { - wsClient.close() - } - }, []) + if (!inPluginLegacy) { + useEffect(() => { + wsClient.open() + return () => { + wsClient.close() + } + }, []) + } useEffect(() => { if (me) {