@@ -15,8 +15,8 @@ import {
15
15
useState ,
16
16
} from 'react' ;
17
17
import { capitalize , Tab , Tabs , useTheme } from '@mui/material' ;
18
- import { Groups , ManageAccounts , PeopleAlt , NotificationImportant } from '@mui/icons-material' ;
19
- import { fetchAppsMetadata , logout , Metadata , TopBar , useNotificationsListener } from '@gridsuite/commons-ui' ;
18
+ import { Groups , ManageAccounts , NotificationImportant , PeopleAlt } from '@mui/icons-material' ;
19
+ import { fetchAppsMetadata , logout , Metadata , TopBar , useGlobalAnnouncement } from '@gridsuite/commons-ui' ;
20
20
import { useParameterState } from '../parameters' ;
21
21
import { APP_NAME , PARAM_LANGUAGE , PARAM_THEME } from '../../utils/config-params' ;
22
22
import { NavLink , type To , useMatches , useNavigate } from 'react-router' ;
@@ -29,7 +29,6 @@ import AppPackage from '../../../package.json';
29
29
import { AppState } from '../../redux/reducer' ;
30
30
import { AppDispatch } from '../../redux/store' ;
31
31
import { MainPaths } from '../../routes/utils' ;
32
- import { NOTIFICATIONS_URL_KEYS } from '../../utils/notifications-provider' ;
33
32
34
33
const tabs = new Map < MainPaths , ReactElement > ( [
35
34
[
@@ -112,31 +111,7 @@ const AppTopBar: FunctionComponent = () => {
112
111
113
112
const [ appsAndUrls , setAppsAndUrls ] = useState < Metadata [ ] > ( [ ] ) ;
114
113
115
- const [ announcementInfos , setAnnouncementInfos ] = useState < AnnouncementProps | null > ( null ) ;
116
-
117
- useNotificationsListener ( NOTIFICATIONS_URL_KEYS . GLOBAL_CONFIG , {
118
- listenerCallbackMessage : ( event ) => {
119
- const eventData = JSON . parse ( event . data ) ;
120
- if ( eventData . headers . messageType === 'announcement' ) {
121
- if (
122
- announcementInfos != null &&
123
- announcementInfos . announcementId === eventData . headers . announcementId
124
- ) {
125
- // If we receive a notification for an announcement that we already received we ignore it
126
- return ;
127
- }
128
- const announcement = {
129
- announcementId : eventData . headers . announcementId ,
130
- message : eventData . payload ,
131
- severity : eventData . headers . severity ,
132
- duration : eventData . headers . duration ,
133
- } as AnnouncementProps ;
134
- setAnnouncementInfos ( announcement ) ;
135
- } else if ( eventData . headers . messageType === 'cancelAnnouncement' ) {
136
- setAnnouncementInfos ( null ) ;
137
- }
138
- } ,
139
- } ) ;
114
+ const announcementInfos = useGlobalAnnouncement ( user ) ;
140
115
141
116
useEffect ( ( ) => {
142
117
if ( user !== null ) {
0 commit comments