@@ -4,6 +4,7 @@ import React, {
44
55import classNames from 'classnames' ;
66import PropTypes from 'prop-types' ;
7+ import { useSearchParams } from 'react-router-dom' ;
78
89import { getConfig } from '@edx/frontend-platform' ;
910import { useIntl } from '@edx/frontend-platform/i18n' ;
@@ -26,12 +27,14 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
2627 const intl = useIntl ( ) ;
2728 const popoverRef = useRef ( null ) ;
2829 const headerRef = useRef ( null ) ;
30+ const [ searchParams ] = useSearchParams ( ) ;
2931 const buttonRef = useRef ( null ) ;
3032 const [ enableNotificationTray , setEnableNotificationTray ] = useState ( false ) ;
3133 const [ appName , setAppName ] = useState ( 'discussion' ) ;
3234 const [ isHeaderVisible , setIsHeaderVisible ] = useState ( true ) ;
3335 const [ notificationData , setNotificationData ] = useState ( { } ) ;
3436 const [ tabsCount , setTabsCount ] = useState ( notificationAppData ?. tabsCount ) ;
37+ const [ openFlag , setOpenFlag ] = useState ( false ) ;
3538 const isOnMediumScreen = useIsOnMediumScreen ( ) ;
3639 const isOnLargeScreen = useIsOnLargeScreen ( ) ;
3740
@@ -45,6 +48,15 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
4548 }
4649 } , [ ] ) ;
4750
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+
4860 useEffect ( ( ) => {
4961 setTabsCount ( notificationAppData . tabsCount ) ;
5062 setNotificationData ( prevData => ( {
@@ -97,10 +109,10 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
97109
98110 const notificationContextValue = useMemo ( ( ) => ( {
99111 enableNotificationTray,
100- appName,
101112 handleActiveTab,
102113 updateNotificationData,
103114 ...notificationData ,
115+ appName,
104116 } ) , [ enableNotificationTray , appName , handleActiveTab , updateNotificationData , notificationData ] ) ;
105117
106118 return (
0 commit comments