From 913ec149dddbacc6b0dfedd75ad14c13ec2fd3bc Mon Sep 17 00:00:00 2001 From: Peter Marshall Date: Mon, 18 Jan 2021 13:33:29 +0100 Subject: [PATCH] [startup] Wait until settings are loaded to load locale data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we want to give users a setting to choose their locale, then we need to wait until settings are available to load the locale data. This CL reorders startup so that we load up settings/prefs first. Also promisify prefs loading so that it's easier to follow ordering in MainImpl. Bug: 1167695 Change-Id: I0955e04a0b5f204c8784be2cad7e6b9fa5443b8b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2635657 Reviewed-by: Simon Zünd Commit-Queue: Peter Marshall --- front_end/main/MainImpl.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/front_end/main/MainImpl.js b/front_end/main/MainImpl.js index 5a37ae67dc..1fd41aac71 100644 --- a/front_end/main/MainImpl.js +++ b/front_end/main/MainImpl.js @@ -84,8 +84,14 @@ export class MainImpl { await Root.Runtime.appStarted; Root.Runtime.Runtime.setPlatform(Host.Platform.platform()); Root.Runtime.Runtime.setL10nCallback(ls); + const prefs = await new Promise(resolve => { + Host.InspectorFrontendHost.InspectorFrontendHostInstance.getPreferences(resolve); + }); + + console.timeStamp('Main._gotPreferences'); + this._createSettings(prefs); await this.requestAndRegisterLocaleData(); - Host.InspectorFrontendHost.InspectorFrontendHostInstance.getPreferences(this._gotPreferences.bind(this)); + this._createAppUI(); } async requestAndRegisterLocaleData() { @@ -101,15 +107,6 @@ export class MainImpl { } } - /** - * @param {!Object} prefs - */ - _gotPreferences(prefs) { - console.timeStamp('Main._gotPreferences'); - this._createSettings(prefs); - this._createAppUI(); - } - /** * @param {!Object} prefs * Note: this function is called from testSettings in Tests.js.