diff --git a/src/components/Dashboard/common/ObjectKanban.jsx b/src/components/Dashboard/common/ObjectKanban.jsx index f8cd096b..4a88e3eb 100644 --- a/src/components/Dashboard/common/ObjectKanban.jsx +++ b/src/components/Dashboard/common/ObjectKanban.jsx @@ -13,6 +13,7 @@ import { Flex } from 'antd' import PropTypes from 'prop-types' import classNames from 'classnames' import { ApiServerContext } from '../context/ApiServerContext' +import { AuthContext } from '../context/AuthContext' import ObjectCard from './ObjectCard' import ObjectKanbanColumn from './ObjectKanbanColumn' import ObjectKanbanHeader from './ObjectKanbanHeader' @@ -285,6 +286,7 @@ const ObjectKanban = forwardRef( subscribeToAllObjectUpdates, subscribeToObjectTypeUpdates } = useContext(ApiServerContext) + const { token } = useContext(AuthContext) const columnRefs = useRef({}) const headerTrackRef = useRef(null) const skeletonTrackRef = useRef(null) @@ -698,19 +700,27 @@ const ObjectKanban = forwardRef( useEffect(() => { return () => { - if (connected == true && subscribeToObjectTypeUpdatesRef.current) { + if ( + connected == true && + token && + subscribeToObjectTypeUpdatesRef.current + ) { subscribeToObjectTypeUpdatesRef.current() subscribeToObjectTypeUpdatesRef.current = null } - if (connected == true && subscribeToAllObjectUpdatesRef.current) { + if ( + connected == true && + token && + subscribeToAllObjectUpdatesRef.current + ) { subscribeToAllObjectUpdatesRef.current() subscribeToAllObjectUpdatesRef.current = null } } - }, [connected]) + }, [connected, token]) useEffect(() => { - if (connected !== true || !type) return + if (connected !== true || !type || !token) return const unsubscribe = subscribeToAllObjectUpdates( type, @@ -725,10 +735,10 @@ const ObjectKanban = forwardRef( subscribeToAllObjectUpdatesRef.current = null } } - }, [type, connected, subscribeToAllObjectUpdates]) + }, [type, connected, subscribeToAllObjectUpdates, token]) useEffect(() => { - if (connected !== true) return + if (connected !== true || !token) return if (subscribedTypeRef.current === type) return const unsubscribe = subscribeToObjectTypeUpdatesFnRef.current( @@ -747,7 +757,7 @@ const ObjectKanban = forwardRef( subscribedTypeRef.current = null } } - }, [type, connected]) + }, [type, connected, token]) useImperativeHandle( ref, diff --git a/src/components/Dashboard/common/ObjectTimeline.jsx b/src/components/Dashboard/common/ObjectTimeline.jsx index 2295e700..0461c3c6 100644 --- a/src/components/Dashboard/common/ObjectTimeline.jsx +++ b/src/components/Dashboard/common/ObjectTimeline.jsx @@ -16,6 +16,7 @@ import ObjectTimelineRow from './ObjectTimelineRow' import { getTimelineRangeFromValues, getTimelineTicks } from './timelineUtils' import cn from 'classnames' import { getStateTagInfo } from '../utils/Utils' +import { AuthContext } from '../context/AuthContext' const { Text } = Typography const LABEL_WIDTH = 226 @@ -40,7 +41,8 @@ const ObjectTimeline = ({ onScroll, rowWrapper }) => { - const { getModelPropertyValues } = useContext(ApiServerContext) + const { getModelPropertyValues, connected } = useContext(ApiServerContext) + const { token } = useContext(AuthContext) const getModelPropertyValuesRef = useRef(getModelPropertyValues) getModelPropertyValuesRef.current = getModelPropertyValues @@ -60,6 +62,8 @@ const ObjectTimeline = ({ ) useEffect(() => { + if (connected !== true || !token) return + if (!type || !startDate) { setStartValues([]) setEndValues([]) @@ -105,7 +109,7 @@ const ObjectTimeline = ({ return () => { cancelled = true } - }, [endDate, rangeQueryKey, startDate, type]) + }, [endDate, rangeQueryKey, startDate, type, connected, token]) const [showShadow, setShowShadow] = useState(false)