@@ -2,10 +2,7 @@ import { Meteor } from 'meteor/meteor'
22import { DDP } from 'meteor/ddp'
33import * as React from 'react'
44import * as _ from 'underscore'
5-
6- import { Translated } from './ReactMeteorData/react-meteor-data'
75import { MomentFromNow } from './Moment'
8-
96import {
107 NotificationCenter ,
118 NoticeLevel ,
@@ -14,13 +11,14 @@ import {
1411 NotifierHandle ,
1512} from './notifications/notifications'
1613import { WithManagedTracker } from './reactiveData/reactiveDataHelper'
17- import { withTranslation } from 'react-i18next'
14+ import { useTranslation } from 'react-i18next'
1815import { NotificationCenterPopUps } from './notifications/NotificationCenterPanel'
1916import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
2017import { ICoreSystem , ServiceMessage , Criticality } from '@sofie-automation/meteor-lib/dist/collections/CoreSystem'
2118import { TFunction } from 'react-i18next'
2219import { getRandomId } from '@sofie-automation/corelib/dist/lib'
2320import { CoreSystem } from '../collections'
21+ import { useEffect } from 'react'
2422
2523export class ConnectionStatusNotifier extends WithManagedTracker {
2624 private _notificationList : NotificationList
@@ -233,30 +231,16 @@ function createSystemNotification(cs: ICoreSystem | undefined): Notification | u
233231 return undefined
234232}
235233
236- interface IProps { }
237- interface IState {
238- dismissed : boolean
239- }
240-
241- export const ConnectionStatusNotification = withTranslation ( ) (
242- class ConnectionStatusNotification extends React . Component < Translated < IProps > , IState > {
243- private notifier : ConnectionStatusNotifier | undefined
244-
245- constructor ( props : Translated < IProps > ) {
246- super ( props )
247- }
234+ export function ConnectionStatusNotification ( ) : JSX . Element {
235+ const { t } = useTranslation ( )
248236
249- componentDidMount ( ) : void {
250- this . notifier = new ConnectionStatusNotifier ( this . props . t )
251- }
237+ useEffect ( ( ) => {
238+ const notifier = new ConnectionStatusNotifier ( t )
252239
253- componentWillUnmount ( ) : void {
254- if ( this . notifier ) this . notifier . stop ( )
240+ return ( ) => {
241+ notifier . stop ( )
255242 }
243+ } , [ t ] )
256244
257- render ( ) : JSX . Element {
258- // this.props.connected
259- return < NotificationCenterPopUps />
260- }
261- }
262- )
245+ return < NotificationCenterPopUps />
246+ }
0 commit comments