Skip to content

Commit bc37582

Browse files
fix: fixed code nits
1 parent ce15f2d commit bc37582

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/Notification/index.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
4949
}, []);
5050

5151
useEffect(() => {
52-
const openTray = searchParams.get('showNotifications') === 'true';
53-
const app = searchParams.get('app') || 'discussion';
54-
if (!openFlag && Object.keys(tabsCount).length > 0) {
55-
setAppName(app);
56-
setEnableNotificationTray(openTray);
57-
setOpenFlag(true);
52+
if (openFlag || Object.keys(tabsCount).length === 0) {
53+
return;
5854
}
55+
setAppName(searchParams.get('app') || 'discussion');
56+
setEnableNotificationTray(searchParams.get('showNotifications') === 'true');
57+
setOpenFlag(true);
5958
}, [tabsCount, openFlag, searchParams]);
6059

6160
useEffect(() => {

src/Notification/index.test.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,13 @@ describe('Notification test cases.', () => {
7171
}
7272

7373
it.each(['true', 'false', null])(
74-
'Notification tray opens when showNotifications query param is %s',
74+
'Ensures correct rendering of the notification tray based on the showNotifications query parameter value %s',
7575
async (showNotifications) => {
7676
await setupMockNotificationCountResponse();
7777

78-
let url = '/';
79-
if (showNotifications !== null) {
80-
url = `/?showNotifications=${showNotifications}`;
81-
}
78+
const url = showNotifications ? `/?showNotifications=${showNotifications}` : '/';
8279
await renderComponent(url);
83-
await waitFor(async () => {
80+
await waitFor(() => {
8481
expect(screen.queryByTestId('notification-bell-icon')).toBeInTheDocument();
8582
if (showNotifications === 'true') {
8683
expect(screen.queryByTestId('notification-tray')).toBeInTheDocument();

0 commit comments

Comments
 (0)