@@ -4,6 +4,7 @@ import React, {
4
4
5
5
import classNames from 'classnames' ;
6
6
import PropTypes from 'prop-types' ;
7
+ import { useSearchParams } from 'react-router-dom' ;
7
8
8
9
import { getConfig } from '@edx/frontend-platform' ;
9
10
import { useIntl } from '@edx/frontend-platform/i18n' ;
@@ -26,12 +27,14 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
26
27
const intl = useIntl ( ) ;
27
28
const popoverRef = useRef ( null ) ;
28
29
const headerRef = useRef ( null ) ;
30
+ const [ searchParams ] = useSearchParams ( ) ;
29
31
const buttonRef = useRef ( null ) ;
30
32
const [ enableNotificationTray , setEnableNotificationTray ] = useState ( false ) ;
31
33
const [ appName , setAppName ] = useState ( 'discussion' ) ;
32
34
const [ isHeaderVisible , setIsHeaderVisible ] = useState ( true ) ;
33
35
const [ notificationData , setNotificationData ] = useState ( { } ) ;
34
36
const [ tabsCount , setTabsCount ] = useState ( notificationAppData ?. tabsCount ) ;
37
+ const [ openFlag , setOpenFlag ] = useState ( false ) ;
35
38
const isOnMediumScreen = useIsOnMediumScreen ( ) ;
36
39
const isOnLargeScreen = useIsOnLargeScreen ( ) ;
37
40
@@ -45,6 +48,15 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
45
48
}
46
49
} , [ ] ) ;
47
50
51
+ useEffect ( ( ) => {
52
+ if ( openFlag || Object . keys ( tabsCount ) . length === 0 ) {
53
+ return ;
54
+ }
55
+ setAppName ( searchParams . get ( 'app' ) || 'discussion' ) ;
56
+ setEnableNotificationTray ( searchParams . get ( 'showNotifications' ) === 'true' ) ;
57
+ setOpenFlag ( true ) ;
58
+ } , [ tabsCount , openFlag , searchParams ] ) ;
59
+
48
60
useEffect ( ( ) => {
49
61
setTabsCount ( notificationAppData . tabsCount ) ;
50
62
setNotificationData ( prevData => ( {
@@ -97,10 +109,10 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
97
109
98
110
const notificationContextValue = useMemo ( ( ) => ( {
99
111
enableNotificationTray,
100
- appName,
101
112
handleActiveTab,
102
113
updateNotificationData,
103
114
...notificationData ,
115
+ appName,
104
116
} ) , [ enableNotificationTray , appName , handleActiveTab , updateNotificationData , notificationData ] ) ;
105
117
106
118
return (
0 commit comments