From 2646948fbf03f6f4881a8d6c0872053d22bb3f79 Mon Sep 17 00:00:00 2001 From: siiky Date: Wed, 14 Feb 2024 13:51:48 +0000 Subject: [PATCH] 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. --- lib/notifier/queries.js | 2 +- .../src/components/NotificationCenter/NotificationCenter.js | 2 -- .../src/components/NotificationCenter/NotificationRow.js | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/notifier/queries.js b/lib/notifier/queries.js index d89e74fb..60b8e0d8 100644 --- a/lib/notifier/queries.js +++ b/lib/notifier/queries.js @@ -54,7 +54,7 @@ const getValidNotifications = (type, detail) => { } 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) } const setRead = (id, read) => { diff --git a/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js b/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js index 67095851..d4aa8be8 100644 --- a/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js +++ b/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js @@ -25,7 +25,6 @@ const GET_NOTIFICATIONS = gql` message created read - valid } hasUnreadNotifications machines { @@ -106,7 +105,6 @@ 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 f5cdea17..87682409 100644 --- a/new-lamassu-admin/src/components/NotificationCenter/NotificationRow.js +++ b/new-lamassu-admin/src/components/NotificationCenter/NotificationRow.js @@ -44,7 +44,6 @@ const NotificationRow = ({ deviceName, created, read, - valid, toggleClear }) => { const classes = useStyles() @@ -72,7 +71,7 @@ const NotificationRow = ({
{icon}