Fix: stop polling notifications after logout

This commit is contained in:
csrapr 2021-05-07 20:02:28 +01:00 committed by Josh Harvey
parent 7657da5e16
commit 952113e3d8

View file

@ -69,7 +69,7 @@ const Header = memo(({ tree, user }) => {
const [active, setActive] = useState()
const [hasUnread, setHasUnread] = useState(false)
const { data, refetch } = useQuery(HAS_UNREAD, { pollInterval: 60000 })
const { data, refetch, startPolling, stopPolling } = useQuery(HAS_UNREAD)
const notifCenterButtonRef = useRef()
const popperRef = useRef()
const history = useHistory()
@ -81,6 +81,11 @@ const Header = memo(({ tree, user }) => {
if (notNil(data?.hasUnreadNotifications)) return setHasUnread(false)
}, [data])
useEffect(() => {
startPolling(60000)
return stopPolling
})
const onPaired = machine => {
setOpen(false)
history.push('/maintenance/machine-status', { id: machine.deviceId })