@@ -131,6 +131,7 @@ function App() {
131131 const [ form , setForm ] = useState ( EMPTY_FORM ) ;
132132 const [ groupSelectValue , setGroupSelectValue ] = useState ( "" ) ;
133133 const [ logDrawerWidth , setLogDrawerWidth ] = useState ( 540 ) ;
134+ const [ updateStatus , setUpdateStatus ] = useState ( { checking : false , message : "" , type : "" } ) ;
134135 const [ columnWidths , setColumnWidths ] = useState ( {
135136 name : 2.2 ,
136137 status : 1 ,
@@ -455,6 +456,25 @@ function App() {
455456 setLogTail ( "" ) ;
456457 }
457458
459+ async function handleCheckForUpdates ( ) {
460+ setUpdateStatus ( { checking : true , message : t ( "checkingForUpdates" ) , type : "" } ) ;
461+ try {
462+ const result = await window . commandHub . checkForUpdates ( ) ;
463+ if ( result . ok ) {
464+ setTimeout ( ( ) => {
465+ setUpdateStatus ( { checking : false , message : t ( "noUpdatesAvailable" ) , type : "success" } ) ;
466+ setTimeout ( ( ) => setUpdateStatus ( { checking : false , message : "" , type : "" } ) , 3000 ) ;
467+ } , 500 ) ;
468+ } else {
469+ setUpdateStatus ( { checking : false , message : t ( "checkUpdateError" , { error : result . error } ) , type : "error" } ) ;
470+ setTimeout ( ( ) => setUpdateStatus ( { checking : false , message : "" , type : "" } ) , 5000 ) ;
471+ }
472+ } catch ( error ) {
473+ setUpdateStatus ( { checking : false , message : t ( "checkUpdateError" , { error : error . message } ) , type : "error" } ) ;
474+ setTimeout ( ( ) => setUpdateStatus ( { checking : false , message : "" , type : "" } ) , 5000 ) ;
475+ }
476+ }
477+
458478 function toggleSort ( nextKey ) {
459479 if ( sortKey === nextKey ) {
460480 setSortDirection ( ( current ) => ( current === "asc" ? "desc" : "asc" ) ) ;
@@ -1066,10 +1086,20 @@ function App() {
10661086 < span className = "switch-slider" />
10671087 </ label >
10681088 </ div >
1089+ < div className = "pref-row" >
1090+ < div className = "pref-copy" >
1091+ < div className = "pref-title" > { t ( "checkForUpdates" ) } </ div >
1092+ < div className = "pref-help" > { updateStatus . message || t ( "settingsDesc" ) } </ div >
1093+ </ div >
1094+ < button className = { `btn btn-md ${ updateStatus . type === "error" ? "danger" : "ghost" } ` } onClick = { handleCheckForUpdates } disabled = { updateStatus . checking } >
1095+ { updateStatus . checking ? t ( "checkingForUpdates" ) : t ( "checkForUpdates" ) }
1096+ </ button >
1097+ </ div >
10691098 </ div >
10701099 </ div >
10711100 </ section >
10721101 ) }
1102+ )}
10731103 </ main >
10741104
10751105 < div className = { `modal-backdrop ${ drawerOpen ? "open" : "" } ` } onClick = { ( ) => setDrawerOpen ( false ) } >
0 commit comments