From 17b8011ce1630bdc0d5481a9a84c775a6dbc5494 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 24 Oct 2024 12:00:13 +0800 Subject: [PATCH] Remove redundant check from --- Server/controllers/monitorController.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Server/controllers/monitorController.js b/Server/controllers/monitorController.js index 582625e32..f157b2fdd 100644 --- a/Server/controllers/monitorController.js +++ b/Server/controllers/monitorController.js @@ -402,14 +402,13 @@ const editMonitor = async (req, res, next) => { await req.db.deleteNotificationsByMonitorId(editedMonitor._id); - if (notifications && notifications.length !== 0) { - await Promise.all( + await Promise.all( + notifications && notifications.map(async (notification) => { notification.monitorId = editedMonitor._id; await req.db.createNotification(notification); }) - ); - } + ); // Delete the old job(editedMonitor has the same ID as the old monitor) await req.jobQueue.deleteJob(monitorBeforeEdit);