From 571a3533fb839cb4386cf4a5f467cef776ffab6c Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Thu, 30 Jan 2020 16:53:14 +0100 Subject: [PATCH] Load settings before rendering the app Change-type: patch --- lib/gui/app/app.ts | 14 ++++++++++++-- .../featured-project/featured-project.tsx | 3 +-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/gui/app/app.ts b/lib/gui/app/app.ts index 9475af88..952c0b11 100644 --- a/lib/gui/app/app.ts +++ b/lib/gui/app/app.ts @@ -336,6 +336,16 @@ window.addEventListener('touchstart', extendLock); // Initial update lock acquisition extendLock(); -settings.load().catch(exceptionReporter.report); +async function main(): Promise { + try { + await settings.load(); + } catch (error) { + exceptionReporter.report(error); + } + ReactDOM.render( + React.createElement(MainPage), + document.getElementById('main'), + ); +} -ReactDOM.render(React.createElement(MainPage), document.getElementById('main')); +main(); diff --git a/lib/gui/app/components/featured-project/featured-project.tsx b/lib/gui/app/components/featured-project/featured-project.tsx index 49426a8d..98d39d54 100644 --- a/lib/gui/app/components/featured-project/featured-project.tsx +++ b/lib/gui/app/components/featured-project/featured-project.tsx @@ -37,9 +37,8 @@ export class FeaturedProject extends React.Component< this.state = { endpoint: null }; } - public async componentDidMount() { + public componentDidMount() { try { - await settings.load(); const endpoint = settings.get('featuredProjectEndpoint') || 'https://assets.balena.io/etcher-featured/index.html';