Skip to content

Commit

Permalink
perf: updated onChannelToggle to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
eemaanamir committed Jan 24, 2024
1 parent 36f7c93 commit 09c02cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/notification-preferences/NotificationPreferenceApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const NotificationPreferenceApp = ({ appId }) => {
const { id: notificationChannel } = event.target;
const isPreferenceNonEditable = (preference) => nonEditable?.[preference.id]?.includes(notificationChannel);

Check warning on line 32 in src/notification-preferences/NotificationPreferenceApp.jsx

View check run for this annotation

Codecov / codecov/patch

src/notification-preferences/NotificationPreferenceApp.jsx#L31-L32

Added lines #L31 - L32 were not covered by tests

const activePreferences = appPreferences.filter(
const hasActivePreferences = appPreferences.some(

Check warning on line 34 in src/notification-preferences/NotificationPreferenceApp.jsx

View check run for this annotation

Codecov / codecov/patch

src/notification-preferences/NotificationPreferenceApp.jsx#L34

Added line #L34 was not covered by tests
(preference) => preference[notificationChannel] && !isPreferenceNonEditable(preference),
);

dispatch(updateChannelPreferenceToggle(courseId, appId, notificationChannel, activePreferences.length === 0));
dispatch(updateChannelPreferenceToggle(courseId, appId, notificationChannel, !hasActivePreferences));

Check warning on line 38 in src/notification-preferences/NotificationPreferenceApp.jsx

View check run for this annotation

Codecov / codecov/patch

src/notification-preferences/NotificationPreferenceApp.jsx#L38

Added line #L38 was not covered by tests
}, [appId, appPreferences, courseId, dispatch, nonEditable]);

const preferences = useMemo(() => (
Expand Down

0 comments on commit 09c02cb

Please sign in to comment.