From bc0e3bb3177d4a1982e544fb6652030e7b6a0a4f Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Thu, 3 Jun 2021 23:39:29 -0500 Subject: [PATCH 1/3] Add warning dialog when custom config.json is invalid Signed-off-by: Aaron Raimist --- src/electron-main.js | 10 ++++++++++ src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/electron-main.js b/src/electron-main.js index 3966834..f3d05b0 100644 --- a/src/electron-main.js +++ b/src/electron-main.js @@ -207,6 +207,16 @@ async function setupGlobals() { vectorConfig = Object.assign(vectorConfig, localConfig); } catch (e) { + if (e instanceof SyntaxError) { + dialog.showMessageBox({ + type: "error", + title: _t("Your %(brand)s is misconfigured", { brand: vectorConfig.brand || 'Element'}), + message: _t("Your custom %(brand)s configuration contains invalid JSON. " + + "Please correct the problem and reopen %(brand)s.", { brand: vectorConfig.brand || 'Element'}), + detail: e.message || "", + }); + } + // Could not load local config, this is expected in most cases. } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b5a97fc..769f23c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1,4 +1,6 @@ { + "Your %(brand)s is misconfigured": "Your %(brand)s is misconfigured", + "Your custom %(brand)s configuration contains invalid JSON. Please correct the problem and reopen %(brand)s.": "Your custom %(brand)s configuration contains invalid JSON. Please correct the problem and reopen %(brand)s.", "Cancel": "Cancel", "Close Element": "Close Element", "Are you sure you want to quit?": "Are you sure you want to quit?", From f109065606875c1b96ef6112586260d310c45733 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Fri, 4 Jun 2021 00:22:59 -0500 Subject: [PATCH 2/3] lint Signed-off-by: Aaron Raimist --- src/electron-main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/electron-main.js b/src/electron-main.js index f3d05b0..ddfa28c 100644 --- a/src/electron-main.js +++ b/src/electron-main.js @@ -210,9 +210,10 @@ async function setupGlobals() { if (e instanceof SyntaxError) { dialog.showMessageBox({ type: "error", - title: _t("Your %(brand)s is misconfigured", { brand: vectorConfig.brand || 'Element'}), + title: _t("Your %(brand)s is misconfigured", { brand: vectorConfig.brand || 'Element' }), message: _t("Your custom %(brand)s configuration contains invalid JSON. " + - "Please correct the problem and reopen %(brand)s.", { brand: vectorConfig.brand || 'Element'}), + "Please correct the problem and reopen %(brand)s.", + { brand: vectorConfig.brand || 'Element' }), detail: e.message || "", }); } From 03e59aa60c57bbb7cabbf1aa547e6e6ef217f838 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Fri, 4 Jun 2021 17:17:58 -0500 Subject: [PATCH 3/3] Remove translation Signed-off-by: Aaron Raimist --- src/electron-main.js | 7 +++---- src/i18n/strings/en_EN.json | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/electron-main.js b/src/electron-main.js index ddfa28c..81df140 100644 --- a/src/electron-main.js +++ b/src/electron-main.js @@ -210,10 +210,9 @@ async function setupGlobals() { if (e instanceof SyntaxError) { dialog.showMessageBox({ type: "error", - title: _t("Your %(brand)s is misconfigured", { brand: vectorConfig.brand || 'Element' }), - message: _t("Your custom %(brand)s configuration contains invalid JSON. " + - "Please correct the problem and reopen %(brand)s.", - { brand: vectorConfig.brand || 'Element' }), + title: `Your ${vectorConfig.brand || 'Element'} is misconfigured`, + message: `Your custom ${vectorConfig.brand || 'Element'} configuration contains invalid JSON. ` + + `Please correct the problem and reopen ${vectorConfig.brand || 'Element'}.`, detail: e.message || "", }); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 769f23c..b5a97fc 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1,6 +1,4 @@ { - "Your %(brand)s is misconfigured": "Your %(brand)s is misconfigured", - "Your custom %(brand)s configuration contains invalid JSON. Please correct the problem and reopen %(brand)s.": "Your custom %(brand)s configuration contains invalid JSON. Please correct the problem and reopen %(brand)s.", "Cancel": "Cancel", "Close Element": "Close Element", "Are you sure you want to quit?": "Are you sure you want to quit?",