mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Typescript: Completed about app
This commit is contained in:
parent
e49537479c
commit
fd883f36fa
@ -8,6 +8,15 @@ import { windowHandler } from './window-handler';
|
||||
let protocolWindow: Electron.WebContents;
|
||||
let protocolUrl: string | undefined;
|
||||
|
||||
/**
|
||||
* Caches the protocol uri
|
||||
* @param {String} uri - the uri opened in the format 'symphony://...'
|
||||
*/
|
||||
const setProtocolUrl = (uri: string): void => {
|
||||
logger.info(`Setting the property protocol url to ${uri}`);
|
||||
protocolUrl = uri;
|
||||
};
|
||||
|
||||
/**
|
||||
* Processes a protocol uri
|
||||
* @param {String} uri - the uri opened in the format 'symphony://abc?def=ghi'
|
||||
@ -27,34 +36,6 @@ const processProtocolUri = (uri: string): void => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Processes protocol action for windows clients
|
||||
* @param argv {Array} an array of command line arguments
|
||||
* @param isAppAlreadyOpen {Boolean} whether the app is already open
|
||||
*/
|
||||
const processProtocolArgv = (argv: string[], isAppAlreadyOpen: boolean): void => {
|
||||
|
||||
// In case of windows, we need to handle protocol handler
|
||||
// manually because electron doesn't emit
|
||||
// 'open-url' event on windows
|
||||
if (!(process.platform === 'win32')) {
|
||||
logger.info('This is windows, not processing protocol url through arguments');
|
||||
return;
|
||||
}
|
||||
|
||||
const protocolUri = getCommandLineArgs(argv, 'symphony://', false);
|
||||
logger.info(`Trying to process a protocol action for uri ${protocolUri}`);
|
||||
|
||||
if (protocolUri) {
|
||||
const parsedURL = url.parse(protocolUri);
|
||||
if (!parsedURL.protocol || !parsedURL.slashes) {
|
||||
return;
|
||||
}
|
||||
logger.info(`Successfully parsed protocol url for ${parsedURL}`);
|
||||
handleProtocolAction(protocolUri, isAppAlreadyOpen);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles a protocol action based on the current state of the app
|
||||
* @param uri
|
||||
@ -86,6 +67,34 @@ const handleProtocolAction = (uri: string, isAppAlreadyOpen: boolean): void => {
|
||||
processProtocolUri(uri);
|
||||
};
|
||||
|
||||
/**
|
||||
* Processes protocol action for windows clients
|
||||
* @param argv {Array} an array of command line arguments
|
||||
* @param isAppAlreadyOpen {Boolean} whether the app is already open
|
||||
*/
|
||||
const processProtocolArgv = (argv: string[], isAppAlreadyOpen: boolean): void => {
|
||||
|
||||
// In case of windows, we need to handle protocol handler
|
||||
// manually because electron doesn't emit
|
||||
// 'open-url' event on windows
|
||||
if (!(process.platform === 'win32')) {
|
||||
logger.info('This is windows, not processing protocol url through arguments');
|
||||
return;
|
||||
}
|
||||
|
||||
const protocolUri = getCommandLineArgs(argv, 'symphony://', false);
|
||||
logger.info(`Trying to process a protocol action for uri ${protocolUri}`);
|
||||
|
||||
if (protocolUri) {
|
||||
const parsedURL = url.parse(protocolUri);
|
||||
if (!parsedURL.protocol || !parsedURL.slashes) {
|
||||
return;
|
||||
}
|
||||
logger.info(`Successfully parsed protocol url for ${parsedURL}`);
|
||||
handleProtocolAction(protocolUri, isAppAlreadyOpen);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the protocol window
|
||||
* @param {Object} win - the renderer window
|
||||
@ -108,15 +117,6 @@ const checkProtocolAction = (): void => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Caches the protocol uri
|
||||
* @param {String} uri - the uri opened in the format 'symphony://...'
|
||||
*/
|
||||
const setProtocolUrl = (uri: string): void => {
|
||||
logger.info(`Setting the property protocol url to ${uri}`);
|
||||
protocolUrl = uri;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the protocol url set against an instance
|
||||
* @returns {*}
|
||||
|
@ -80,7 +80,7 @@ export class WindowHandler {
|
||||
|
||||
try {
|
||||
const extra = { podUrl: this.globalConfig.url, process: 'main' };
|
||||
crashReporter.start({ ...this.globalConfig.crashReporter, ...extra });
|
||||
crashReporter.start({ ...this.globalConfig.crashReporter, extra });
|
||||
} catch (e) {
|
||||
throw new Error('failed to init crash report');
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
|
||||
import AboutBox from './about-app';
|
||||
import LoadingScreen from './loading-screen';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', load);
|
||||
|
||||
@ -12,20 +9,14 @@ document.addEventListener('DOMContentLoaded', load);
|
||||
*/
|
||||
export function load() {
|
||||
const query = new URL(window.location.href).searchParams;
|
||||
const componentName = query.get('componentName');
|
||||
const componentName = query.get('component');
|
||||
|
||||
let component;
|
||||
switch (componentName) {
|
||||
case 'about-app':
|
||||
component = AboutBox;
|
||||
break;
|
||||
case 'loading-screen':
|
||||
component = LoadingScreen;
|
||||
break;
|
||||
}
|
||||
|
||||
ipcRenderer.on('data', (__: Electron.Event, args) => {
|
||||
const element = React.createElement(component, args);
|
||||
ReactDOM.render(element, document.getElementById('Root'));
|
||||
});
|
||||
const element = React.createElement(component);
|
||||
ReactDOM.render(element, document.getElementById('Root'));
|
||||
}
|
Loading…
Reference in New Issue
Block a user