Skip to content

Commit

Permalink
fix: hide BrowserWindows before showing dialog
Browse files Browse the repository at this point in the history
on linux we show webui on startup because tray icon is not always
available, and showDialog's blocking nature freezes it mid-load.

What is worse, that broken BrowserWindow may be on top of the dialog,
leaving user confused why everything froze.

This solves the problem by hiding all windows before showing the final
dialog
  • Loading branch information
lidel committed Mar 25, 2022
1 parent 51ff30a commit 6a64e98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
"message": "IPFS node has encountered an error and startup could not be completed:"
},
"invalidRepositoryDialog": {
"title": "Invalid Repository",
"message": "The repository at { path } is invalid. The configuration file .ipfs/config must be a valid JSON file.\n\nBefore starting IPFS Desktop again, please fix the configuration file or rename the old repository to .ipfs.backup."
"title": "Invalid IPFS Repository or Configuration File",
"message": "The repository at { path } is invalid. The “config” file must be a valid JSON.\n\nBefore starting IPFS Desktop again, please fix the configuration file or rename the old repository to .ipfs.backup."
}
}
10 changes: 9 additions & 1 deletion src/daemon/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app } = require('electron')
const { app, BrowserWindow } = require('electron')
const { join } = require('path')
const fs = require('fs-extra')
const { multiaddr } = require('multiaddr')
Expand Down Expand Up @@ -339,12 +339,20 @@ function checkValidConfig (ipfsd) {
readConfigFile(ipfsd)
return true
} catch (e) {
// Save to error.log
logger.error(e)

// Hide other windows so the user focus in on the dialog
BrowserWindow.getAllWindows().forEach(w => w.hide())

// Show blocking dialog
showDialog({
title: i18n.t('invalidRepositoryDialog.title'),
message: i18n.t('invalidRepositoryDialog.message', { path: ipfsd.path }),
buttons: [i18n.t('quit')]
})

// Only option is to quit
app.quit()
}
}
Expand Down

0 comments on commit 6a64e98

Please sign in to comment.