mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-154 - Modified the code to open the main window after reading the config fields
This commit is contained in:
committed by
Kiran Niranjan
parent
4f4fc69f85
commit
a1dfea70bb
17
js/main.js
17
js/main.js
@@ -11,6 +11,7 @@ const urlParser = require('url');
|
||||
|
||||
// Local Dependencies
|
||||
const {getConfigField, updateUserConfigWin, updateUserConfigMac} = require('./config.js');
|
||||
const {setCheckboxValues} = require('./menus/menuTemplate.js');
|
||||
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||
const protocolHandler = require('./protocolHandler');
|
||||
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
||||
@@ -92,7 +93,7 @@ if (isMac) {
|
||||
* initialization and is ready to create browser windows.
|
||||
* Some APIs can only be used after this event occurs.
|
||||
*/
|
||||
app.on('ready', setupThenOpenMainWindow);
|
||||
app.on('ready', readConfigThenOpenMainWindow);
|
||||
|
||||
/**
|
||||
* Is triggered when all the windows are closed
|
||||
@@ -127,6 +128,20 @@ app.on('open-url', function(event, url) {
|
||||
handleProtocolAction(url);
|
||||
});
|
||||
|
||||
/**
|
||||
* Reads the config fields that are required for the menu items
|
||||
* then opens the main window
|
||||
*
|
||||
* This is a workaround for the issue where the menu template was returned
|
||||
* even before the config data was populated
|
||||
* https://perzoinc.atlassian.net/browse/ELECTRON-154
|
||||
*/
|
||||
function readConfigThenOpenMainWindow() {
|
||||
setCheckboxValues()
|
||||
.then(setupThenOpenMainWindow)
|
||||
.catch(setupThenOpenMainWindow)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the app (to handle various things like config changes, protocol handling etc.)
|
||||
* and opens the main window
|
||||
|
||||
@@ -13,8 +13,6 @@ let minimizeOnClose = false;
|
||||
let launchOnStartup = false;
|
||||
let isAlwaysOnTop = false;
|
||||
|
||||
setCheckboxValues();
|
||||
|
||||
let symphonyAutoLauncher;
|
||||
|
||||
if (isMac) {
|
||||
@@ -266,6 +264,7 @@ function getTemplate(app) {
|
||||
* based on configuration
|
||||
*/
|
||||
function setCheckboxValues() {
|
||||
return new Promise((resolve) => {
|
||||
/**
|
||||
* Method that reads multiple config fields
|
||||
*/
|
||||
@@ -292,11 +291,14 @@ function setCheckboxValues() {
|
||||
}
|
||||
}
|
||||
}
|
||||
return resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
let title = 'Error loading configuration';
|
||||
log.send(logLevels.ERROR, 'MenuTemplate: error reading configuration fields, error: ' + err);
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -306,5 +308,6 @@ function getMinimizeOnClose() {
|
||||
|
||||
module.exports = {
|
||||
getTemplate: getTemplate,
|
||||
getMinimizeOnClose: getMinimizeOnClose
|
||||
getMinimizeOnClose: getMinimizeOnClose,
|
||||
setCheckboxValues: setCheckboxValues
|
||||
};
|
||||
Reference in New Issue
Block a user