SymphonyElectron/js/bringToFront.js
Kiran Niranjan ecb0f88660 Electron-336 (Update bring to front logic on Windows) (#325)
- Added an arg which prevents window from getting focus when it is set to false
- Update bring to front logic
- Rename "Bring to Front on Notifications" to Flash Notification in Taskbar for Windows
- Update Spectron test cases
2018-03-16 12:26:07 +05:30

31 lines
1.0 KiB
JavaScript

'use strict';
const windowMgr = require('./windowMgr.js');
const { getConfigField } = require('./config.js');
const log = require('./log.js');
const logLevels = require('./enums/logLevels.js');
/**
* Method that checks if user has enabled the bring to front feature
* if so then activates the main window
* @param {String} windowName - Name of the window to activate
* @param {String} reason - The reason for which the window is to be activated
*/
function bringToFront(windowName, reason) {
getConfigField('bringToFront')
.then((bringToFrontSetting) => {
if (typeof bringToFrontSetting === 'boolean' && bringToFrontSetting) {
log.send(logLevels.INFO, 'Window has been activated for: ' + reason);
windowMgr.activate(windowName || 'main', false);
}
})
.catch((error) => {
log.send(logLevels.ERROR, 'Could not read bringToFront field from config error= ' + error);
});
}
module.exports = {
bringToFront: bringToFront
};