Skip to content

Commit 2d08325

Browse files
committed
fixup! feat: notification count from notification plugin in course outline
1 parent 6064fd5 commit 2d08325

6 files changed

Lines changed: 21 additions & 23 deletions

File tree

src/course-outline/CourseOutline.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ const CourseOutline = () => {
344344
courseId={courseId}
345345
isLoading={isLoading}
346346
statusBarData={statusBarData}
347-
notificationCount={3}
348347
/>
349348
) : (
350349
<LegacyStatusBar

src/course-outline/status-bar/NotificationStatusIcon.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ function useDynamicHookShim() {
2121

2222
async function load() {
2323
try {
24-
const module = await import("@edx/frontend-plugin-notifications");
24+
// eslint-disable-next-line import/no-extraneous-dependencies
25+
const module = await import('@edx/frontend-plugin-notifications');
2526
const hookFn = module.useAppNotifications ?? module.default;
2627
if (!cancelled) {
2728
// `module.useAppNotifications` is itself a hook
2829
setHook(() => hookFn);
2930
}
3031
} catch (err: any) {
31-
// If the module cannot be found, just keep `hook` as null.
32-
console.error("Failed to load notifications plugin:", err);
33-
// No hook – the UI will fall back to the placeholder.
32+
// eslint-disable-next-line no-console
33+
console.error('Failed to load notifications plugin:', err);
3434
}
3535
}
3636

@@ -45,7 +45,7 @@ function useDynamicHookShim() {
4545
}
4646

4747
// Component that actually calls the loaded hook
48-
function NotificationHookConsumer({ hook }: { hook: () => HooKType }) {
48+
const NotificationHookConsumer = ({ hook }: { hook: () => HooKType }) => {
4949
// The hook is now called on **every** render of this component
5050
const { notificationAppData } = hook();
5151

@@ -63,7 +63,7 @@ function NotificationHookConsumer({ hook }: { hook: () => HooKType }) {
6363
/>
6464
</small>
6565
);
66-
}
66+
};
6767

6868
// Main component
6969
export const NotificationStatusIcon = () => {
@@ -76,4 +76,3 @@ export const NotificationStatusIcon = () => {
7676
// Once loaded, delegate to a component that calls the hook
7777
return <NotificationHookConsumer hook={loadedHook} />;
7878
};
79-

src/course-outline/status-bar/StatusBar.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Badge, Icon, Stack } from '@openedx/paragon';
55
import { Link } from 'react-router-dom';
66

77
import { CourseOutlineStatusBar } from '@src/course-outline/data/types';
8-
import { ChecklistRtl, NotificationsNone } from '@openedx/paragon/icons';
8+
import { ChecklistRtl } from '@openedx/paragon/icons';
99
import messages from './messages';
1010
import { useWaffleFlags } from '../../data/apiHooks';
1111
import { NotificationStatusIcon } from './NotificationStatusIcon';
@@ -89,14 +89,12 @@ export interface StatusBarProps {
8989
courseId: string;
9090
isLoading: boolean;
9191
statusBarData: CourseOutlineStatusBar;
92-
notificationCount?: number;
9392
}
9493

9594
export const StatusBar = ({
9695
statusBarData,
9796
isLoading,
9897
courseId,
99-
notificationCount,
10098
}: StatusBarProps) => {
10199
const intl = useIntl();
102100
const waffleFlags = useWaffleFlags(courseId);
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
export const useAppNotifications = () => {
2-
return {
3-
notificationAppData: {
4-
tabsCount: {
5-
count: 0,
6-
}
7-
}
8-
};
9-
};
1+
export const useAppNotifications = () => ({
2+
notificationAppData: {
3+
tabsCount: {
4+
count: 0,
5+
},
6+
},
7+
});
108

11-
export const NotificationsTray = () => <></>;
9+
export const NotificationsTray = () => null;

webpack.dev.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path');
22
const { createConfig } = require('@openedx/frontend-build');
3+
// eslint-disable-next-line import/no-extraneous-dependencies
34
const webpack = require('webpack');
45

56
const config = createConfig('webpack-dev', {
@@ -25,9 +26,10 @@ const config = createConfig('webpack-dev', {
2526
require.resolve('@edx/frontend-plugin-notifications');
2627
} catch (e) {
2728
// Package not found → point to the stub we created.
29+
// eslint-disable-next-line no-param-reassign
2830
resource.request = path.resolve(__dirname, 'src/stubs/empty-notifications-plugin.tsx');
2931
}
30-
}
32+
},
3133
),
3234
],
3335
});

webpack.prod.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path');
22
const { createConfig } = require('@openedx/frontend-build');
3+
// eslint-disable-next-line import/no-extraneous-dependencies
34
const webpack = require('webpack');
45

56
const config = createConfig('webpack-prod', {
@@ -25,9 +26,10 @@ const config = createConfig('webpack-prod', {
2526
require.resolve('@edx/frontend-plugin-notifications');
2627
} catch (e) {
2728
// Package not found → point to the stub we created.
29+
// eslint-disable-next-line no-param-reassign
2830
resource.request = path.resolve(__dirname, 'src/stubs/empty-notifications-plugin.tsx');
2931
}
30-
}
32+
},
3133
),
3234
],
3335
});

0 commit comments

Comments
 (0)