1
1
import { useEffect } from 'react'
2
2
import { useDispatch , useSelector } from 'react-redux'
3
3
import { useHistory } from 'react-router-dom'
4
+ import { UpdateInfo } from 'electron-updater'
4
5
import { IParsedDeepLink } from 'desktopSrc/lib/app/deep-link.handlers'
5
6
import {
6
7
appServerInfoSelector ,
7
- appElectronInfoSelector
8
+ appElectronInfoSelector ,
8
9
} from 'uiSrc/slices/app/info'
9
- import { ipcCheckUpdates , ipcSendEvents } from 'uiSrc/electron/utils'
10
+ import { ipcAppRestart , ipcCheckUpdates , ipcSendEvents } from 'uiSrc/electron/utils'
10
11
import { ipcDeleteDownloadedVersion } from 'uiSrc/electron/utils/ipcDeleteStoreValues'
12
+ import { addInfiniteNotification } from 'uiSrc/slices/app/notifications'
13
+ import { INFINITE_MESSAGES } from 'uiSrc/components/notifications/components'
14
+ import { TelemetryEvent , sendEventTelemetry } from 'uiSrc/telemetry'
11
15
12
16
const ConfigElectron = ( ) => {
13
17
let isCheckedUpdates = false
@@ -19,6 +23,7 @@ const ConfigElectron = () => {
19
23
20
24
useEffect ( ( ) => {
21
25
window . app ?. deepLinkAction ?.( deepLinkAction )
26
+ window . app ?. updateAvailable ?.( updateAvailableAction )
22
27
} , [ ] )
23
28
24
29
useEffect ( ( ) => {
@@ -48,6 +53,14 @@ const ConfigElectron = () => {
48
53
}
49
54
}
50
55
56
+ const updateAvailableAction = ( _e : any , { version } : UpdateInfo ) => {
57
+ sendEventTelemetry ( { event : TelemetryEvent . UPDATE_NOTIFICATION_DISPLAYED } )
58
+ dispatch ( addInfiniteNotification ( INFINITE_MESSAGES . APP_UPDATE_AVAILABLE ( version , ( ) => {
59
+ sendEventTelemetry ( { event : TelemetryEvent . UPDATE_NOTIFICATION_RESTART_CLICKED } )
60
+ ipcAppRestart ( )
61
+ } ) ) )
62
+ }
63
+
51
64
return null
52
65
}
53
66
0 commit comments