mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-01-03 12:47:13 -06:00
cda34b1d70
* added idea and coverage directories under gitignore * electron-24: implemented handlers to process protocol actions * electron-17: implemented use case for opening app if it is not open and handle the protocol url * electron-24: added code and documentation comments * electron-24: added unit tests for the protocol handler * added npm-debug log to gitignore * electron-24: added protocol handler support for windows * electron-24: made changes as per comments on the PR * electron-16: added more comments and further refactoring
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
let protocolWindow;
|
|
let protocolUrl;
|
|
|
|
/**
|
|
* processes a protocol uri
|
|
* @param {String} uri - the uri opened in the format 'symphony://...'
|
|
*/
|
|
function processProtocolAction(uri) {
|
|
if (protocolWindow && uri && uri.startsWith("symphony://")) {
|
|
protocolWindow.send('protocol-action', uri);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* sets the protocol window
|
|
* @param {Object} win - the renderer window
|
|
*/
|
|
function setProtocolWindow(win) {
|
|
protocolWindow = win;
|
|
}
|
|
|
|
/**
|
|
* checks to see if the app was opened by a uri
|
|
*/
|
|
function checkProtocolAction() {
|
|
if (protocolUrl) {
|
|
processProtocolAction(protocolUrl);
|
|
protocolUrl = undefined;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* caches the protocol uri
|
|
* @param {String} uri - the uri opened in the format 'symphony://...'
|
|
*/
|
|
function setProtocolUrl(uri) {
|
|
protocolUrl = uri;
|
|
}
|
|
|
|
function getProtocolUrl() {
|
|
return protocolUrl;
|
|
}
|
|
|
|
module.exports = {
|
|
processProtocolAction: processProtocolAction,
|
|
setProtocolWindow: setProtocolWindow,
|
|
checkProtocolAction: checkProtocolAction,
|
|
setProtocolUrl: setProtocolUrl,
|
|
getProtocolUrl: getProtocolUrl
|
|
};
|