refactor: ignore invalid notifications
`lib/notifier/queries.js:getNotifications()` is only used in `lib/new-admin/graphql/resolvers/notification.resolver.js`. In the UI, the `valid` field is only used together with the `read` field, with a true value.
This commit is contained in:
parent
24d0973f12
commit
2646948fbf
3 changed files with 2 additions and 5 deletions
|
|
@ -54,7 +54,7 @@ const getValidNotifications = (type, detail) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getNotifications = () => {
|
const getNotifications = () => {
|
||||||
const sql = `SELECT * FROM notifications ORDER BY created DESC`
|
const sql = `SELECT * FROM notifications WHERE valid ORDER BY created DESC`
|
||||||
return db.any(sql).catch(logger.error)
|
return db.any(sql).catch(logger.error)
|
||||||
}
|
}
|
||||||
const setRead = (id, read) => {
|
const setRead = (id, read) => {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ const GET_NOTIFICATIONS = gql`
|
||||||
message
|
message
|
||||||
created
|
created
|
||||||
read
|
read
|
||||||
valid
|
|
||||||
}
|
}
|
||||||
hasUnreadNotifications
|
hasUnreadNotifications
|
||||||
machines {
|
machines {
|
||||||
|
|
@ -106,7 +105,6 @@ const NotificationCenter = ({
|
||||||
deviceName={machines[n.detail.deviceId]}
|
deviceName={machines[n.detail.deviceId]}
|
||||||
created={n.created}
|
created={n.created}
|
||||||
read={n.read}
|
read={n.read}
|
||||||
valid={n.valid}
|
|
||||||
toggleClear={() =>
|
toggleClear={() =>
|
||||||
toggleClearNotification({
|
toggleClearNotification({
|
||||||
variables: { id: n.id, read: !n.read }
|
variables: { id: n.id, read: !n.read }
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ const NotificationRow = ({
|
||||||
deviceName,
|
deviceName,
|
||||||
created,
|
created,
|
||||||
read,
|
read,
|
||||||
valid,
|
|
||||||
toggleClear
|
toggleClear
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
@ -72,7 +71,7 @@ const NotificationRow = ({
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
classes.notificationRow,
|
classes.notificationRow,
|
||||||
!read && valid ? classes.unread : ''
|
!read ? classes.unread : ''
|
||||||
)}>
|
)}>
|
||||||
<div className={classes.notificationRowIcon}>
|
<div className={classes.notificationRowIcon}>
|
||||||
<div>{icon}</div>
|
<div>{icon}</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue