From 6a64e9843064f5c4e5c94e737f1980eb2d2b2939 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 25 Mar 2022 23:00:03 +0100 Subject: [PATCH] fix: hide BrowserWindows before showing dialog 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 --- assets/locales/en.json | 4 ++-- src/daemon/config.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/locales/en.json b/assets/locales/en.json index 36ee520c4..053436fb1 100644 --- a/assets/locales/en.json +++ b/assets/locales/en.json @@ -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”." } } diff --git a/src/daemon/config.js b/src/daemon/config.js index 8010e28de..5042cf9d3 100644 --- a/src/daemon/config.js +++ b/src/daemon/config.js @@ -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') @@ -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() } }