Skip to content

Commit 022515d

Browse files
Merge pull request #355 from openedx/sundas/INF-903
feat: binded show notification tray status with the backend api
2 parents 911cea6 + 2d737aa commit 022515d

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

src/Notifications/data/__factories__/notifications.factory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Factory.define('notificationsCount')
88
grades: 10,
99
authoring: 5,
1010
})
11-
.attr('showNotificationTray', true);
11+
.attr('showNotificationsTray', true);
1212

1313
Factory.define('notification')
1414
.sequence('id')

src/Notifications/data/redux.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('Notification Redux', () => {
6262
expect(notifications.apps).toEqual({});
6363
expect(notifications.notifications).toEqual({});
6464
expect(notifications.tabsCount).toEqual({});
65-
expect(notifications.showNotificationTray).toEqual(false);
65+
expect(notifications.showNotificationsTray).toEqual(false);
6666
expect(notifications.pagination.count).toEqual(10);
6767
expect(notifications.pagination.numPages).toEqual(1);
6868
expect(notifications.pagination.currentPage).toEqual(1);

src/Notifications/data/selectors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const selectNotificationTabs = () => state => state.notifications.appsId;
88

99
export const selectSelectedAppNotificationIds = (appName) => state => state.notifications.apps[appName] ?? [];
1010

11-
export const selectShowNotificationTray = () => state => state.notifications.showNotificationTray;
11+
export const selectShowNotificationTray = () => state => state.notifications.showNotificationsTray;
1212

1313
export const selectNotifications = () => state => state.notifications.notifications;
1414

src/Notifications/data/slice.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const initialState = {
1616
apps: {},
1717
notifications: {},
1818
tabsCount: {},
19-
showNotificationTray: false,
19+
showNotificationsTray: false,
2020
pagination: {
2121
count: 10,
2222
numPages: 1,
@@ -62,12 +62,12 @@ const slice = createSlice({
6262
},
6363
fetchNotificationsCountSuccess: (state, { payload }) => {
6464
const {
65-
countByAppName, appIds, apps, count, showNotificationTray,
65+
countByAppName, appIds, apps, count, showNotificationsTray,
6666
} = payload;
6767
state.tabsCount = { count, ...countByAppName };
6868
state.appsId = appIds;
6969
state.apps = apps;
70-
state.showNotificationTray = showNotificationTray;
70+
state.showNotificationsTray = showNotificationsTray;
7171
state.notificationStatus = RequestStatus.LOADED;
7272
},
7373
markNotificationsAsSeenRequest: (state) => {

src/Notifications/data/thunks.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import {
2727
} from './api';
2828
import { getHttpErrorStatus } from '../utils';
2929

30-
const normalizeNotificationCounts = ({ countByAppName, count, showNotificationTray }) => {
30+
const normalizeNotificationCounts = ({ countByAppName, count, showNotificationsTray }) => {
3131
const appIds = Object.keys(countByAppName);
3232
const apps = appIds.reduce((acc, appId) => { acc[appId] = []; return acc; }, {});
3333
return {
34-
countByAppName, appIds, apps, count, showNotificationTray,
34+
countByAppName, appIds, apps, count, showNotificationsTray,
3535
};
3636
};
3737

@@ -66,12 +66,7 @@ export const fetchAppsNotificationCount = () => (
6666
dispatch(fetchNotificationsCountRequest());
6767
const data = await getNotificationCounts();
6868
const normalisedData = normalizeNotificationCounts((camelCaseObject(data)));
69-
dispatch(fetchNotificationsCountSuccess({
70-
...normalisedData,
71-
countByAppName: data.countByAppName,
72-
count: data.count,
73-
showNotificationTray: data.showNotificationTray,
74-
}));
69+
dispatch(fetchNotificationsCountSuccess({ ...normalisedData }));
7570
} catch (error) {
7671
if (getHttpErrorStatus(error) === 403) {
7772
dispatch(fetchNotificationsCountDenied());

src/learning-header/AuthenticatedUserDropdown.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { RequestStatus } from '../Notifications/data/slice';
1515
import messages from './messages';
1616

1717
const AuthenticatedUserDropdown = ({ intl, username }) => {
18-
const showNotificationTray = useSelector(selectShowNotificationTray());
18+
const showNotificationsTray = useSelector(selectShowNotificationTray());
1919
const notificationStatus = useSelector(selectNotificationStatus());
2020
const dispatch = useDispatch();
2121

@@ -35,7 +35,7 @@ const AuthenticatedUserDropdown = ({ intl, username }) => {
3535
return (
3636
<>
3737
<a className="text-gray-700" href={`${getConfig().SUPPORT_URL}`}>{intl.formatMessage(messages.help)}</a>
38-
{showNotificationTray && <Notifications />}
38+
{showNotificationsTray && <Notifications />}
3939
<Dropdown className="user-dropdown ml-3">
4040
<Dropdown.Toggle variant="outline-primary">
4141
<FontAwesomeIcon icon={faUserCircle} className="d-md-none" size="lg" />

0 commit comments

Comments
 (0)