From a18d924ffbb7ad48b25813442dfcbfb91bf48451 Mon Sep 17 00:00:00 2001 From: siiky Date: Wed, 20 Mar 2024 12:29:49 +0000 Subject: [PATCH] refactor: show invalid notifs again --- lib/notifier/queries.js | 6 +++--- .../src/components/NotificationCenter/NotificationCenter.js | 2 ++ .../src/components/NotificationCenter/NotificationRow.js | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/notifier/queries.js b/lib/notifier/queries.js index b1e92ab0..5a51e695 100644 --- a/lib/notifier/queries.js +++ b/lib/notifier/queries.js @@ -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) diff --git a/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js b/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js index d4aa8be8..67095851 100644 --- a/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js +++ b/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js @@ -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 } diff --git a/new-lamassu-admin/src/components/NotificationCenter/NotificationRow.js b/new-lamassu-admin/src/components/NotificationCenter/NotificationRow.js index 87682409..f5cdea17 100644 --- a/new-lamassu-admin/src/components/NotificationCenter/NotificationRow.js +++ b/new-lamassu-admin/src/components/NotificationCenter/NotificationRow.js @@ -44,6 +44,7 @@ const NotificationRow = ({ deviceName, created, read, + valid, toggleClear }) => { const classes = useStyles() @@ -71,7 +72,7 @@ const NotificationRow = ({
{icon}