diff --git a/src/notification-preferences/NotificationPreferenceRow.jsx b/src/notification-preferences/NotificationPreferenceRow.jsx index 72b2299d6..0e9b971fe 100644 --- a/src/notification-preferences/NotificationPreferenceRow.jsx +++ b/src/notification-preferences/NotificationPreferenceRow.jsx @@ -11,8 +11,10 @@ import { selectPreference, selectPreferenceNonEditableChannels, selectSelectedCourseId, + selectNotificationPreferencesStatus, } from './data/selectors'; import { updatePreferenceToggle } from './data/thunks'; +import { LOADING_STATUS } from '../constants'; const NotificationPreferenceRow = ({ appId, preferenceName }) => { const dispatch = useDispatch(); @@ -20,6 +22,7 @@ const NotificationPreferenceRow = ({ appId, preferenceName }) => { const courseId = useSelector(selectSelectedCourseId()); const preference = useSelector(selectPreference(appId, preferenceName)); const nonEditable = useSelector(selectPreferenceNonEditableChannels(appId, preferenceName)); + const preferencesStatus = useSelector(selectNotificationPreferencesStatus()); const onToggle = useCallback((event) => { const { @@ -73,7 +76,7 @@ const NotificationPreferenceRow = ({ appId, preferenceName }) => { name={channel} value={preference[channel]} onChange={onToggle} - disabled={nonEditable.includes(channel)} + disabled={nonEditable.includes(channel) || preferencesStatus === LOADING_STATUS} /> ))} diff --git a/src/notification-preferences/data/reducers.js b/src/notification-preferences/data/reducers.js index cbdc83a56..e27935f92 100644 --- a/src/notification-preferences/data/reducers.js +++ b/src/notification-preferences/data/reducers.js @@ -102,6 +102,7 @@ const notificationPreferencesReducer = (state = defaultState, action = {}) => { ? { ...preference, [notificationChannel]: value } : preference )), + status: LOADING_STATUS, }, }; case Actions.UPDATE_APP_PREFERENCE: diff --git a/src/notification-preferences/data/thunks.js b/src/notification-preferences/data/thunks.js index dcc865f5f..86ff5c0f8 100644 --- a/src/notification-preferences/data/thunks.js +++ b/src/notification-preferences/data/thunks.js @@ -126,7 +126,7 @@ export const updatePreferenceToggle = ( notificationApp, notificationType, notificationChannel, - value, + !value, )); const data = await patchPreferenceToggle( courseId,