mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-500 / ELECTRON-384: fix protocol handler non-window use case (#372)
- fix issue in protocol handler when app is not initialized - fix formatting issues
This commit is contained in:
committed by
GitHub
parent
8037d16000
commit
c36b639296
@@ -364,17 +364,15 @@ function processProtocolAction(argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let protocolUri = getCmdLineArg(argv, 'symphony://', false);
|
let protocolUri = getCmdLineArg(argv, 'symphony://', false);
|
||||||
|
log.send(logLevels.INFO, `Trying to process a protocol action for uri ${protocolUri}`);
|
||||||
|
|
||||||
if (protocolUri) {
|
if (protocolUri) {
|
||||||
|
|
||||||
const parsedURL = urlParser.parse(protocolUri);
|
const parsedURL = urlParser.parse(protocolUri);
|
||||||
|
|
||||||
if (!parsedURL.protocol || !parsedURL.slashes) {
|
if (!parsedURL.protocol || !parsedURL.slashes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
log.send(logLevels.INFO, `Parsing protocol url successful for ${parsedURL}`);
|
||||||
handleProtocolAction(protocolUri);
|
handleProtocolAction(protocolUri);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,10 +382,12 @@ function processProtocolAction(argv) {
|
|||||||
*/
|
*/
|
||||||
function handleProtocolAction(uri) {
|
function handleProtocolAction(uri) {
|
||||||
if (!isAppAlreadyOpen) {
|
if (!isAppAlreadyOpen) {
|
||||||
|
log.send(logLevels.INFO, `App started by protocol url ${uri}. We are caching this to be processed later!`);
|
||||||
// app is opened by the protocol url, cache the protocol url to be used later
|
// app is opened by the protocol url, cache the protocol url to be used later
|
||||||
protocolHandler.setProtocolUrl(uri);
|
protocolHandler.setProtocolUrl(uri);
|
||||||
} else {
|
} else {
|
||||||
// app is already open, so, just trigger the protocol action method
|
// app is already open, so, just trigger the protocol action method
|
||||||
|
log.send(logLevels.INFO, `App opened by protocol url ${uri}`);
|
||||||
protocolHandler.processProtocolAction(uri);
|
protocolHandler.processProtocolAction(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,13 @@ let protocolUrl;
|
|||||||
* @param {String} uri - the uri opened in the format 'symphony://...'
|
* @param {String} uri - the uri opened in the format 'symphony://...'
|
||||||
*/
|
*/
|
||||||
function processProtocolAction(uri) {
|
function processProtocolAction(uri) {
|
||||||
log.send(logLevels.INFO, 'protocol action, uri=' + uri);
|
log.send(logLevels.INFO, `protocol action, uri ${uri}`);
|
||||||
if (protocolWindow && uri && uri.startsWith('symphony://')) {
|
if (!protocolWindow) {
|
||||||
|
log.send(logLevels.INFO, `protocol window not yet initialized, caching the uri ${uri}`);
|
||||||
|
setProtocolUrl(uri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (uri && uri.startsWith('symphony://')) {
|
||||||
protocolWindow.send('protocol-action', uri);
|
protocolWindow.send('protocol-action', uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +34,9 @@ function setProtocolWindow(win) {
|
|||||||
* checks to see if the app was opened by a uri
|
* checks to see if the app was opened by a uri
|
||||||
*/
|
*/
|
||||||
function checkProtocolAction() {
|
function checkProtocolAction() {
|
||||||
|
log.send(logLevels.INFO, `checking if we have a cached protocol url`);
|
||||||
if (protocolUrl) {
|
if (protocolUrl) {
|
||||||
|
log.send(logLevels.INFO, `found a cached protocol url, processing it!`);
|
||||||
processProtocolAction(protocolUrl);
|
processProtocolAction(protocolUrl);
|
||||||
protocolUrl = undefined;
|
protocolUrl = undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user