@@ -266,103 +266,98 @@ export async function helpDialog(defaultTabId = null) {
266266
267267 const upgradeButton = dialog . querySelector ( 'button.upgrade' ) ;
268268
269- // Update status tracking
270- let updateStatus = 'idle' ; // idle, checking, available, downloading, downloaded, error
269+ // Create a new element for update status messages under the button
270+ const updateStatusElement = document . createElement ( 'div' ) ;
271+ updateStatusElement . id = 'update-status-dialog' ;
272+ updateStatusElement . style . marginTop = '10px' ;
273+ updateStatusElement . style . fontSize = '0.9em' ;
274+ updateStatusElement . style . color = 'var(--accent, #3b82f6)' ;
275+ upgradeButton . insertAdjacentElement ( 'afterend' , updateStatusElement ) ;
276+
277+ upgradeButton . textContent = 'Check for Updates' ;
278+ upgradeButton . addEventListener ( 'click' , async ( ) => {
279+ try {
280+ const result = await ipcRenderer . invoke ( 'check-for-updates' ) ;
281+ if ( ! result . success ) {
282+ updateStatusElement . textContent = `Error: ${ result . error } ` ;
283+ updateStatusElement . style . color = 'var(--error, #ef4444)' ;
284+ } else {
285+ updateStatusElement . textContent = 'Checking for updates...' ;
286+ updateStatusElement . style . color = 'var(--accent, #3b82f6)' ;
287+ }
288+ } catch ( error ) {
289+ updateStatusElement . textContent = `Error: ${ error . message } ` ;
290+ updateStatusElement . style . color = 'var(--error, #ef4444)' ;
291+ }
292+ } ) ;
271293
272294 // Listen for update status changes from main process
273295 ipcRenderer . on ( 'update-status' , ( event , status ) => {
274- updateStatus = status . status ;
275- const progressContainer = dialog . querySelector ( '.update-progress' ) ;
276- const progressBar = dialog . querySelector ( '.update-progress-bar' ) ;
277- const progressText = dialog . querySelector ( '.update-progress-text' ) ;
278-
279296 switch ( status . status ) {
280297 case 'checking' :
281- upgradeButton . textContent = 'Checking...' ;
298+ updateStatusElement . textContent = 'Checking for updates...' ;
299+ updateStatusElement . style . color = 'var(--accent, #3b82f6)' ;
282300 upgradeButton . disabled = true ;
283- if ( progressContainer ) progressContainer . style . display = 'none' ;
284301 break ;
285302 case 'available' :
286- upgradeButton . textContent = `Download Update ${ status . version } ` ;
303+ updateStatusElement . textContent = `Update ${ status . version } available! Click to download.` ;
304+ updateStatusElement . style . color = 'var(--success, #10b981)' ;
305+ upgradeButton . textContent = 'Download Update' ;
287306 upgradeButton . disabled = false ;
288- if ( progressContainer ) {
289- progressContainer . className = 'update-progress available' ;
290- progressContainer . style . display = 'block' ;
291- progressBar . style . width = '0%' ;
292- progressText . textContent = 'Update available for download' ;
293- }
307+ upgradeButton . onclick = async ( ) => {
308+ try {
309+ const downloadResult = await ipcRenderer . invoke ( 'download-update' ) ;
310+ if ( ! downloadResult . success ) {
311+ updateStatusElement . textContent = `Download failed: ${ downloadResult . error } ` ;
312+ updateStatusElement . style . color = 'var(--error, #ef4444)' ;
313+ upgradeButton . disabled = false ;
314+ } else {
315+ updateStatusElement . textContent = 'Starting download...' ;
316+ updateStatusElement . style . color = 'var(--accent, #3b82f6)' ;
317+ upgradeButton . disabled = true ;
318+ }
319+ } catch ( error ) {
320+ updateStatusElement . textContent = `Download error: ${ error . message } ` ;
321+ updateStatusElement . style . color = 'var(--error, #ef4444)' ;
322+ upgradeButton . disabled = false ;
323+ }
324+ } ;
294325 break ;
295326 case 'up-to-date' :
296- upgradeButton . textContent = 'Up to Date' ;
297- upgradeButton . disabled = true ;
298- if ( progressContainer ) progressContainer . style . display = 'none' ;
327+ updateStatusElement . textContent = 'You are running the latest version.' ;
328+ updateStatusElement . style . color = 'var(--success, #10b981)' ;
329+ upgradeButton . disabled = false ;
330+ upgradeButton . textContent = 'Check for Updates' ;
299331 break ;
300332 case 'downloading' :
301- upgradeButton . textContent = `Downloading... ${ status . progress } %` ;
333+ updateStatusElement . textContent = `Downloading... ${ status . progress } % (${ status . downloaded } /${ status . total } MB @ ${ status . speed } MB/s)` ;
334+ updateStatusElement . style . color = 'var(--accent, #3b82f6)' ;
302335 upgradeButton . disabled = true ;
303- if ( progressContainer ) {
304- progressContainer . className = 'update-progress downloading' ;
305- progressContainer . style . display = 'block' ;
306- progressBar . style . width = `${ status . progress } %` ;
307- progressText . textContent = `${ status . progress } % (${ status . downloaded } /${ status . total } MB @ ${ status . speed } MB/s)` ;
308- }
336+ upgradeButton . textContent = 'Downloading...' ;
309337 break ;
310338 case 'downloaded' :
339+ updateStatusElement . textContent = 'Download complete! Restart to install.' ;
340+ updateStatusElement . style . color = 'var(--success, #10b981)' ;
311341 upgradeButton . textContent = 'Install & Restart' ;
312342 upgradeButton . disabled = false ;
313- if ( progressContainer ) {
314- progressContainer . style . display = 'none' ;
315- }
343+ upgradeButton . onclick = async ( ) => {
344+ try {
345+ await ipcRenderer . invoke ( 'quit-and-install' ) ;
346+ } catch ( error ) {
347+ updateStatusElement . textContent = `Install error: ${ error . message } ` ;
348+ updateStatusElement . style . color = 'var(--error, #ef4444)' ;
349+ }
350+ } ;
316351 break ;
317352 case 'error' :
318- upgradeButton . textContent = 'Check for Updates' ;
353+ updateStatusElement . textContent = `Update error: ${ status . error } ` ;
354+ updateStatusElement . style . color = 'var(--error, #ef4444)' ;
319355 upgradeButton . disabled = false ;
320- if ( progressContainer ) {
321- progressContainer . className = 'update-progress error' ;
322- progressContainer . style . display = 'block' ;
323- progressBar . style . width = '0%' ;
324- progressText . textContent = `Error: ${ status . error } ` ;
325- }
326- console . error ( 'Update error:' , status . error ) ;
356+ upgradeButton . textContent = 'Check for Updates' ;
327357 break ;
328358 }
329359 } ) ;
330360
331- upgradeButton . addEventListener ( 'click' , async ( ) => {
332- try {
333- switch ( updateStatus ) {
334- case 'idle' :
335- case 'up-to-date' :
336- case 'error' :
337- // Check for updates
338- const result = await ipcRenderer . invoke ( 'check-for-updates' ) ;
339- if ( ! result . success ) {
340- console . error ( 'Failed to check for updates:' , result . error ) ;
341- upgradeButton . textContent = 'Check Failed - Try Again' ;
342- upgradeButton . disabled = false ;
343- }
344- break ;
345- case 'available' :
346- // Start download
347- const downloadResult = await ipcRenderer . invoke ( 'download-update' ) ;
348- if ( ! downloadResult . success ) {
349- console . error ( 'Failed to download update:' , downloadResult . error ) ;
350- upgradeButton . textContent = 'Download Failed - Try Again' ;
351- upgradeButton . disabled = false ;
352- }
353- break ;
354- case 'downloaded' :
355- // Install and restart
356- await ipcRenderer . invoke ( 'quit-and-install' ) ;
357- break ;
358- }
359- } catch ( error ) {
360- console . error ( 'Update operation failed:' , error ) ;
361- upgradeButton . textContent = 'Error - Try Again' ;
362- upgradeButton . disabled = false ;
363- }
364- } ) ;
365-
366361 dialog . querySelector ( 'button.btn-liberapay' ) . addEventListener ( 'click' , ( ) => {
367362 ipcRenderer . invoke ( 'go-to-url' , 'https://liberapay.com/yPhil/' ) ;
368363 } ) ;
0 commit comments