Feat: notification center polling, prevent page moving when opening it
This commit is contained in:
parent
dee7dde195
commit
b89ba7d939
3 changed files with 16 additions and 5 deletions
|
|
@ -53,7 +53,9 @@ const CLEAR_ALL_NOTIFICATIONS = gql`
|
|||
|
||||
const NotificationCenter = ({ close, notifyUnread }) => {
|
||||
const classes = useStyles()
|
||||
const { data, loading } = useQuery(GET_NOTIFICATIONS)
|
||||
const { data, loading } = useQuery(GET_NOTIFICATIONS, {
|
||||
pollInterval: 60000
|
||||
})
|
||||
const [showingUnread, setShowingUnread] = useState(false)
|
||||
const machines = R.compose(
|
||||
R.map(R.prop('name')),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ import Popper from '@material-ui/core/Popper'
|
|||
import { makeStyles } from '@material-ui/core/styles'
|
||||
import classnames from 'classnames'
|
||||
import gql from 'graphql-tag'
|
||||
import React, { memo, useState } from 'react'
|
||||
import * as R from 'ramda'
|
||||
import React, { memo, useState, useEffect } from 'react'
|
||||
import { NavLink, useHistory } from 'react-router-dom'
|
||||
|
||||
import NotificationCenter from 'src/components/NotificationCenter'
|
||||
|
|
@ -56,14 +57,22 @@ const Subheader = ({ item, classes }) => {
|
|||
)
|
||||
}
|
||||
|
||||
const notNil = R.compose(R.not, R.isNil)
|
||||
|
||||
const Header = memo(({ tree }) => {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [anchorEl, setAnchorEl] = React.useState(null)
|
||||
const [active, setActive] = useState()
|
||||
const { data, refetch } = useQuery(HAS_UNREAD)
|
||||
const hasUnread = data?.hasUnreadNotifications ?? false
|
||||
const { data, refetch } = useQuery(HAS_UNREAD, { pollInterval: 60000 })
|
||||
const [hasUnread, setHasUnread] = useState(false)
|
||||
|
||||
const history = useHistory()
|
||||
const classes = useStyles()
|
||||
useEffect(() => {
|
||||
if (data?.hasUnreadNotifications) return setHasUnread(true)
|
||||
// if not true, make sure it's false and not undefined
|
||||
if (notNil(data?.hasUnreadNotifications)) return setHasUnread(false)
|
||||
}, [data])
|
||||
|
||||
const onPaired = machine => {
|
||||
setOpen(false)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export default {
|
|||
},
|
||||
'.root-notifcenter-open': {
|
||||
// for when notification center is open
|
||||
overflowY: 'scroll',
|
||||
overflowY: 'auto',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue