Load settings before rendering the app

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-01-30 16:53:14 +01:00
parent 6fcd9e1595
commit 571a3533fb
2 changed files with 13 additions and 4 deletions

View File

@ -336,6 +336,16 @@ window.addEventListener('touchstart', extendLock);
// Initial update lock acquisition // Initial update lock acquisition
extendLock(); extendLock();
settings.load().catch(exceptionReporter.report); async function main(): Promise<void> {
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();

View File

@ -37,9 +37,8 @@ export class FeaturedProject extends React.Component<
this.state = { endpoint: null }; this.state = { endpoint: null };
} }
public async componentDidMount() { public componentDidMount() {
try { try {
await settings.load();
const endpoint = const endpoint =
settings.get('featuredProjectEndpoint') || settings.get('featuredProjectEndpoint') ||
'https://assets.balena.io/etcher-featured/index.html'; 'https://assets.balena.io/etcher-featured/index.html';