mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
simplify protocol handler api (#96)
* simplify protocol handler api * update registerProtocolHandler doc * more documentation updates
This commit is contained in:
parent
d494e23d4e
commit
c4a3f6c024
@ -10,7 +10,6 @@ const cmds = keyMirror({
|
||||
activate: null,
|
||||
registerBoundsChange: null,
|
||||
registerProtocolHandler: null,
|
||||
checkProtocolAction: null,
|
||||
registerActivityDetection: null,
|
||||
});
|
||||
|
||||
|
@ -70,13 +70,9 @@ electron.ipcMain.on(apiName, (event, arg) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.cmd === apiCmds.checkProtocolAction) {
|
||||
protocolHandler.checkProtocolAction();
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.cmd === apiCmds.registerProtocolHandler) {
|
||||
protocolHandler.setProtocolWindow(event.sender);
|
||||
protocolHandler.checkProtocolAction();
|
||||
}
|
||||
|
||||
if (arg.cmd === apiCmds.badgeDataUrl && typeof arg.dataUrl === 'string' &&
|
||||
|
@ -32,13 +32,6 @@ const throttledSetBadgeCount = throttle(1000, function(count) {
|
||||
});
|
||||
});
|
||||
|
||||
// check to see if the app was opened via a url
|
||||
const checkProtocolAction = function () {
|
||||
local.ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.checkProtocolAction
|
||||
});
|
||||
};
|
||||
|
||||
createAPI();
|
||||
|
||||
// creates API exposed from electron.
|
||||
@ -83,13 +76,6 @@ function createAPI() {
|
||||
throttledSetBadgeCount(count);
|
||||
},
|
||||
|
||||
/**
|
||||
* checks to see if the app was opened from a url.
|
||||
*/
|
||||
checkProtocolAction: function () {
|
||||
checkProtocolAction();
|
||||
},
|
||||
|
||||
/**
|
||||
* provides api similar to html5 Notification, see details
|
||||
* in notify/notifyImpl.js
|
||||
@ -149,11 +135,21 @@ function createAPI() {
|
||||
},
|
||||
|
||||
/**
|
||||
* allows JS to register a protocol handler that can be used by the electron main process.
|
||||
* @param protocolHandler {Object} protocolHandler a callback to register the protocol handler
|
||||
* allows JS to register a protocol handler that can be used by the
|
||||
* electron main process.
|
||||
*
|
||||
* @param protocolHandler {Function} callback will be called when app is
|
||||
* invoked with registered protocol (e.g., symphony). The callback
|
||||
* receives a single string argument: full uri that the app was
|
||||
* invoked with e.g., symphony://?streamId=xyz123&streamType=chatroom
|
||||
*
|
||||
* Note: this function should only be called after client app is fully
|
||||
* able for protocolHandler callback to be invoked. It is possible
|
||||
* the app was started using protocol handler, in this case as soon as
|
||||
* this registration func is invoked then the protocolHandler callback
|
||||
* will be immediately called.
|
||||
*/
|
||||
registerProtocolHandler: function (protocolHandler) {
|
||||
|
||||
if (typeof protocolHandler === 'function') {
|
||||
|
||||
local.processProtocolAction = protocolHandler;
|
||||
@ -163,7 +159,6 @@ function createAPI() {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user