File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ const electronAPI: ElectronAPI = {
4343 ipcRenderer . on ( 'update-downloaded' , listener ) ;
4444 return ( ) => { ipcRenderer . removeListener ( 'update-downloaded' , listener ) ; } ;
4545 } ,
46+ onUpdateError : ( callback : ( info : { message : string } ) => void ) => {
47+ const listener = ( _event : Electron . IpcRendererEvent , info : { message : string } ) => callback ( info ) ;
48+ ipcRenderer . on ( 'update-error' , listener ) ;
49+ return ( ) => { ipcRenderer . removeListener ( 'update-error' , listener ) ; } ;
50+ } ,
4651 checkForUpdates : ( ) => ipcRenderer . invoke ( 'check-for-updates' ) ,
4752 downloadUpdate : ( ) => ipcRenderer . invoke ( 'download-update' ) ,
4853 installUpdate : ( ) => ipcRenderer . invoke ( 'install-update' ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ type UpdateState =
44 | { status : 'idle' }
55 | { status : 'available' ; version : string }
66 | { status : 'downloading' ; percent : number }
7+ | { status : 'error' ; message : string }
78 | { status : 'ready' } ;
89
910export const UpdateNotification : React . FC = ( ) => {
@@ -24,10 +25,15 @@ export const UpdateNotification: React.FC = () => {
2425 setState ( { status : 'ready' } ) ;
2526 } ) ;
2627
28+ const unsubError = window . electronAPI . onUpdateError ( ( info ) => {
29+ setState ( { status : 'error' , message : info . message } ) ;
30+ } ) ;
31+
2732 return ( ) => {
2833 unsubAvailable ( ) ;
2934 unsubProgress ( ) ;
3035 unsubDownloaded ( ) ;
36+ unsubError ( ) ;
3137 } ;
3238 } , [ ] ) ;
3339
@@ -73,6 +79,18 @@ export const UpdateNotification: React.FC = () => {
7379 </ >
7480 ) }
7581
82+ { state . status === 'error' && (
83+ < >
84+ < span className = "update-text" > Update failed: { state . message } </ span >
85+ < button
86+ className = "update-btn update-btn-dismiss"
87+ onClick = { ( ) => setDismissed ( true ) }
88+ >
89+ Dismiss
90+ </ button >
91+ </ >
92+ ) }
93+
7694 { state . status === 'ready' && (
7795 < >
7896 < span className = "update-text" > Update ready to install</ span >
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ export interface ElectronAPI {
9898 onUpdateAvailable : ( callback : ( info : { version : string ; releaseNotes ?: string } ) => void ) => ( ) => void ;
9999 onUpdateDownloadProgress : ( callback : ( info : { percent : number } ) => void ) => ( ) => void ;
100100 onUpdateDownloaded : ( callback : ( ) => void ) => ( ) => void ;
101+ onUpdateError : ( callback : ( info : { message : string } ) => void ) => ( ) => void ;
101102 checkForUpdates : ( ) => Promise < void > ;
102103 downloadUpdate : ( ) => Promise < void > ;
103104 installUpdate : ( ) => Promise < void > ;
You can’t perform that action at this time.
0 commit comments