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
|
// Local Dependencies
|
||||||
const {getConfigField, updateUserConfigWin, updateUserConfigMac} = require('./config.js');
|
const {getConfigField, updateUserConfigWin, updateUserConfigMac} = require('./config.js');
|
||||||
|
const {setCheckboxValues} = require('./menus/menuTemplate.js');
|
||||||
const { isMac, isDevEnv } = require('./utils/misc.js');
|
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||||
const protocolHandler = require('./protocolHandler');
|
const protocolHandler = require('./protocolHandler');
|
||||||
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
||||||
@@ -92,7 +93,7 @@ if (isMac) {
|
|||||||
* initialization and is ready to create browser windows.
|
* initialization and is ready to create browser windows.
|
||||||
* Some APIs can only be used after this event occurs.
|
* 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
|
* Is triggered when all the windows are closed
|
||||||
@@ -127,6 +128,20 @@ app.on('open-url', function(event, url) {
|
|||||||
handleProtocolAction(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.)
|
* Sets up the app (to handle various things like config changes, protocol handling etc.)
|
||||||
* and opens the main window
|
* and opens the main window
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ let minimizeOnClose = false;
|
|||||||
let launchOnStartup = false;
|
let launchOnStartup = false;
|
||||||
let isAlwaysOnTop = false;
|
let isAlwaysOnTop = false;
|
||||||
|
|
||||||
setCheckboxValues();
|
|
||||||
|
|
||||||
let symphonyAutoLauncher;
|
let symphonyAutoLauncher;
|
||||||
|
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
@@ -266,38 +264,42 @@ function getTemplate(app) {
|
|||||||
* based on configuration
|
* based on configuration
|
||||||
*/
|
*/
|
||||||
function setCheckboxValues() {
|
function setCheckboxValues() {
|
||||||
/**
|
return new Promise((resolve) => {
|
||||||
* Method that reads multiple config fields
|
/**
|
||||||
*/
|
* Method that reads multiple config fields
|
||||||
getMultipleConfigField(['minimizeOnClose', 'launchOnStartup', 'alwaysOnTop', 'notificationSettings'])
|
*/
|
||||||
.then(function (configData) {
|
getMultipleConfigField(['minimizeOnClose', 'launchOnStartup', 'alwaysOnTop', 'notificationSettings'])
|
||||||
for (let key in configData) {
|
.then(function (configData) {
|
||||||
if (configData.hasOwnProperty(key)) { // eslint-disable-line no-prototype-builtins
|
for (let key in configData) {
|
||||||
switch (key) {
|
if (configData.hasOwnProperty(key)) { // eslint-disable-line no-prototype-builtins
|
||||||
case 'minimizeOnClose':
|
switch (key) {
|
||||||
minimizeOnClose = configData[key];
|
case 'minimizeOnClose':
|
||||||
break;
|
minimizeOnClose = configData[key];
|
||||||
case 'launchOnStartup':
|
break;
|
||||||
launchOnStartup = configData[key];
|
case 'launchOnStartup':
|
||||||
break;
|
launchOnStartup = configData[key];
|
||||||
case 'alwaysOnTop':
|
break;
|
||||||
isAlwaysOnTop = configData[key];
|
case 'alwaysOnTop':
|
||||||
eventEmitter.emit('isAlwaysOnTop', configData[key]);
|
isAlwaysOnTop = configData[key];
|
||||||
break;
|
eventEmitter.emit('isAlwaysOnTop', configData[key]);
|
||||||
case 'notificationSettings':
|
break;
|
||||||
eventEmitter.emit('notificationSettings', configData[key]);
|
case 'notificationSettings':
|
||||||
break;
|
eventEmitter.emit('notificationSettings', configData[key]);
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return resolve();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
let title = 'Error loading configuration';
|
let title = 'Error loading configuration';
|
||||||
log.send(logLevels.ERROR, 'MenuTemplate: error reading configuration fields, error: ' + err);
|
log.send(logLevels.ERROR, 'MenuTemplate: error reading configuration fields, error: ' + err);
|
||||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||||
});
|
return resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMinimizeOnClose() {
|
function getMinimizeOnClose() {
|
||||||
@@ -306,5 +308,6 @@ function getMinimizeOnClose() {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getTemplate: getTemplate,
|
getTemplate: getTemplate,
|
||||||
getMinimizeOnClose: getMinimizeOnClose
|
getMinimizeOnClose: getMinimizeOnClose,
|
||||||
|
setCheckboxValues: setCheckboxValues
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user