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 getNotifications = () => {
const sql = ` const sql = `
SELECT * FROM notifications SELECT * FROM notifications
WHERE valid AND ${WITHIN_PAST_WEEK} WHERE ${WITHIN_PAST_WEEK}
ORDER BY created DESC ORDER BY created DESC
` `
return db.any(sql).catch(logger.error) return db.any(sql).catch(logger.error)
@ -77,7 +77,7 @@ const hasUnreadNotifications = () => {
const sql = ` const sql = `
SELECT EXISTS SELECT EXISTS
(SELECT * FROM notifications (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) return db.oneOrNone(sql).then(res => res.exists).catch(logger.error)
} }
@ -86,7 +86,7 @@ const getAlerts = () => {
const types = ['fiatBalance', 'cryptoBalance', 'error'] const types = ['fiatBalance', 'cryptoBalance', 'error']
const sql = ` const sql = `
SELECT * FROM notifications 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 ORDER BY created DESC
` `
return db.any(sql, [types]).catch(logger.error) return db.any(sql, [types]).catch(logger.error)

View file

@ -25,6 +25,7 @@ const GET_NOTIFICATIONS = gql`
message message
created created
read read
valid
} }
hasUnreadNotifications hasUnreadNotifications
machines { machines {
@ -105,6 +106,7 @@ 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 }

View file

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