From f6ad5bf54c97c3de61e05e58f34b09c16f131e11 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 8 Apr 2020 20:12:05 +0100 Subject: [PATCH] let settled accept multiple proms + i18n Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/i18n/strings/en_EN.json | 9 +++++---- src/vector/index.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b77de122..3582ca35 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1,11 +1,12 @@ { + "Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.", + "Your Riot is misconfigured": "Your Riot is misconfigured", + "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.", + "Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.", "Your Riot configuration contains invalid JSON. Please correct the problem and reload the page.": "Your Riot configuration contains invalid JSON. Please correct the problem and reload the page.", "The message from the parser is: %(message)s": "The message from the parser is: %(message)s", "Invalid JSON": "Invalid JSON", - "Your Riot is misconfigured": "Your Riot is misconfigured", - "Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.", - "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.", - "Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.", + "Unable to load config file: please refresh the page to try again.": "Unable to load config file: please refresh the page to try again.", "Open user settings": "Open user settings", "Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s", "Go to your browser to complete Sign In": "Go to your browser to complete Sign In", diff --git a/src/vector/index.ts b/src/vector/index.ts index 0d3a8e87..f3c091f5 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -33,11 +33,13 @@ if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js'); } -async function settled(prom: Promise) { - try { - await prom; - } catch (e) { - console.error(e); +async function settled(...promises: Array>) { + for (const prom of promises) { + try { + await prom; + } catch (e) { + console.error(e); + } } } @@ -141,9 +143,7 @@ async function start() { const loadSkinPromise = loadSkin(); // await things settling so that any errors we have to render have features like i18n running - await settled(loadSkinPromise); - await settled(loadThemePromise); - await settled(loadLanguagePromise); + await settled(loadSkinPromise, loadThemePromise, loadLanguagePromise); // ########################## // error handling begins here @@ -173,7 +173,7 @@ async function start() { // await things starting successfully // ################################## await loadOlmPromise; - await settled(loadSkinPromise); + await loadSkinPromise; await loadThemePromise; await loadLanguagePromise;