From 0f2d52020d56ff8f4f31f85f5f0ee0d688db523e Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Thu, 10 May 2018 18:11:52 +0530 Subject: [PATCH] Electron-435 - Optimize reading "isCustomTitleBar" global config field (#365) --- js/windowMgr.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index ca0c165e..f9a9addd 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -93,33 +93,35 @@ function getParsedUrl(appUrl) { * @param initialUrl */ function createMainWindow(initialUrl) { - Promise.all([ - getConfigField('mainWinPos'), - getGlobalConfigField('isCustomTitleBar') - ]).then((values) => { - doCreateMainWindow(initialUrl, values[ 0 ], values[ 1 ]); - }).catch(() => { - // failed use default bounds and frame - doCreateMainWindow(initialUrl, null, false); - }); + getConfigField('mainWinPos') + .then(winPos => { + doCreateMainWindow(initialUrl, winPos); + }) + .catch(() => { + // failed use default bounds and frame + doCreateMainWindow(initialUrl, null); + }); } /** * Creates the main window with bounds * @param initialUrl * @param initialBounds - * @param isCustomTitleBar {Boolean} - Global config value weather to enable custom title bar */ -function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) { +function doCreateMainWindow(initialUrl, initialBounds) { let url = initialUrl; let key = getGuid(); + + const config = readConfigFileSync(); + // condition whether to enable custom Windows 10 title bar - const isCustomTitleBarEnabled = typeof isCustomTitleBar === 'boolean' && isCustomTitleBar && isWindows10(); + const isCustomTitleBarEnabled = config + && typeof config.isCustomTitleBar === 'boolean' + && config.isCustomTitleBar + && isWindows10(); log.send(logLevels.INFO, 'creating main window url: ' + url); - let config = readConfigFileSync(); - if (config && config !== null && config.customFlags) { log.send(logLevels.INFO, 'Chrome flags config found!');