From aeb8109d9471171ad708c3acdd81adef35783987 Mon Sep 17 00:00:00 2001 From: eemaanamir Date: Wed, 24 Jan 2024 13:26:30 +0500 Subject: [PATCH] refactor: onChannelToggle updated --- src/notification-preferences/NotificationPreferenceApp.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/notification-preferences/NotificationPreferenceApp.jsx b/src/notification-preferences/NotificationPreferenceApp.jsx index 7e37a1be1..6eaddfb98 100644 --- a/src/notification-preferences/NotificationPreferenceApp.jsx +++ b/src/notification-preferences/NotificationPreferenceApp.jsx @@ -32,10 +32,11 @@ const NotificationPreferenceApp = ({ appId }) => { const isPreferenceNonEditable = (preference) => nonEditable?.[preference.id]?.includes(notificationChannel) || false; - const truePreferences = appPreferences.filter((preference) => preference[notificationChannel] === true - && !isPreferenceNonEditable(preference)); + const activePreferences = appPreferences.filter( + (preference) => preference[notificationChannel] && !isPreferenceNonEditable(preference), + ); - dispatch(updateChannelPreferenceToggle(courseId, appId, notificationChannel, truePreferences.length === 0)); + dispatch(updateChannelPreferenceToggle(courseId, appId, notificationChannel, activePreferences.length === 0)); }, [appId, appPreferences, courseId, dispatch, nonEditable]); const preferences = useMemo(() => (