Skip to content

Commit

Permalink
refactor: onChannelToggle updated
Browse files Browse the repository at this point in the history
  • Loading branch information
eemaanamir committed Jan 24, 2024
1 parent a6699f9 commit aeb8109
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/notification-preferences/NotificationPreferenceApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => (
Expand Down

0 comments on commit aeb8109

Please sign in to comment.