Fix: stop polling notifications after logout
This commit is contained in:
parent
7657da5e16
commit
952113e3d8
1 changed files with 6 additions and 1 deletions
|
|
@ -69,7 +69,7 @@ const Header = memo(({ tree, user }) => {
|
||||||
const [active, setActive] = useState()
|
const [active, setActive] = useState()
|
||||||
const [hasUnread, setHasUnread] = useState(false)
|
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 notifCenterButtonRef = useRef()
|
||||||
const popperRef = useRef()
|
const popperRef = useRef()
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
|
@ -81,6 +81,11 @@ const Header = memo(({ tree, user }) => {
|
||||||
if (notNil(data?.hasUnreadNotifications)) return setHasUnread(false)
|
if (notNil(data?.hasUnreadNotifications)) return setHasUnread(false)
|
||||||
}, [data])
|
}, [data])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
startPolling(60000)
|
||||||
|
return stopPolling
|
||||||
|
})
|
||||||
|
|
||||||
const onPaired = machine => {
|
const onPaired = machine => {
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
history.push('/maintenance/machine-status', { id: machine.deviceId })
|
history.push('/maintenance/machine-status', { id: machine.deviceId })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue