Disable websockets in shared boards (#1391)

* Disable websockets in shared boards

* Address review comments

* Fix linter
This commit is contained in:
Miguel de la Cruz 2021-10-04 18:01:49 +02:00 committed by GitHub
parent c852ae2802
commit 711da0409f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,6 +81,13 @@ const App = React.memo((): JSX.Element => {
const me = useAppSelector<IUser|null>(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) {