refactor: show invalid notifs again

This commit is contained in:
siiky 2024-03-20 12:29:49 +00:00
parent dcfca2099d
commit a18d924ffb
3 changed files with 7 additions and 4 deletions

View file

@ -58,7 +58,7 @@ const WITHIN_PAST_WEEK = `created > (CURRENT_TIMESTAMP - INTERVAL '7' DAY)`
const getNotifications = () => {
const sql = `
SELECT * FROM notifications
WHERE valid AND ${WITHIN_PAST_WEEK}
WHERE ${WITHIN_PAST_WEEK}
ORDER BY created DESC
`
return db.any(sql).catch(logger.error)
@ -77,7 +77,7 @@ const hasUnreadNotifications = () => {
const sql = `
SELECT EXISTS
(SELECT * FROM notifications
WHERE valid AND NOT read AND ${WITHIN_PAST_WEEK})
WHERE NOT read AND ${WITHIN_PAST_WEEK})
`
return db.oneOrNone(sql).then(res => res.exists).catch(logger.error)
}
@ -86,7 +86,7 @@ const getAlerts = () => {
const types = ['fiatBalance', 'cryptoBalance', 'error']
const sql = `
SELECT * FROM notifications
WHERE valid AND ${WITHIN_PAST_WEEK} AND type IN ($1:list)
WHERE ${WITHIN_PAST_WEEK} AND type IN ($1:list)
ORDER BY created DESC
`
return db.any(sql, [types]).catch(logger.error)

View file

@ -25,6 +25,7 @@ const GET_NOTIFICATIONS = gql`
message
created
read
valid
}
hasUnreadNotifications
machines {
@ -105,6 +106,7 @@ const NotificationCenter = ({
deviceName={machines[n.detail.deviceId]}
created={n.created}
read={n.read}
valid={n.valid}
toggleClear={() =>
toggleClearNotification({
variables: { id: n.id, read: !n.read }

View file

@ -44,6 +44,7 @@ const NotificationRow = ({
deviceName,
created,
read,
valid,
toggleClear
}) => {
const classes = useStyles()
@ -71,7 +72,7 @@ const NotificationRow = ({
<div
className={classnames(
classes.notificationRow,
!read ? classes.unread : ''
!read && valid ? classes.unread : ''
)}>
<div className={classes.notificationRowIcon}>
<div>{icon}</div>