From be6d962cc3462d5eab9b18a9bec1f0140f7d7a72 Mon Sep 17 00:00:00 2001 From: nimbleghost <132819643+nimbleghost@users.noreply.github.com> Date: Wed, 24 May 2023 18:08:59 +0200 Subject: [PATCH] Fix param reassignment issue --- web/src/app/SubscriptionManager.js | 9 ++++++--- web/src/components/Notifications.jsx | 11 +++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/web/src/app/SubscriptionManager.js b/web/src/app/SubscriptionManager.js index 03617e0..ecbe4da 100644 --- a/web/src/app/SubscriptionManager.js +++ b/web/src/app/SubscriptionManager.js @@ -105,9 +105,12 @@ class SubscriptionManager { return false; } try { - // eslint-disable-next-line no-param-reassign - notification.new = 1; // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation - await db.notifications.add({ ...notification, subscriptionId }); // FIXME consider put() for double tab + await db.notifications.add({ + ...notification, + subscriptionId, + // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation + new: 1, + }); // FIXME consider put() for double tab await db.subscriptions.update(subscriptionId, { last: notification.id, }); diff --git a/web/src/components/Notifications.jsx b/web/src/components/Notifications.jsx index 7d4da06..2faf2fd 100644 --- a/web/src/components/Notifications.jsx +++ b/web/src/components/Notifications.jsx @@ -436,15 +436,10 @@ const ACTION_LABEL_SUFFIX = { }; const updateActionStatus = (notification, action, progress, error) => { - // TODO(eslint): Fix by spreading? Does the code depend on the change, though? - // eslint-disable-next-line no-param-reassign - notification.actions = notification.actions.map((a) => { - if (a.id !== action.id) { - return a; - } - return { ...a, progress, error }; + subscriptionManager.updateNotification({ + ...notification, + actions: notification.actions.map((a) => (a.id === action.id ? { ...a, progress, error } : a)), }); - subscriptionManager.updateNotification(notification); }; const performHttpAction = async (notification, action) => {