mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
Typescript (Fix issues with setting the window origin) (#663)
* Typescript - Fix issues with setting the window origin * Typescript - Fix lint issue * Typescript - Fix frequent window activation
This commit is contained in:
parent
bc7b815e2c
commit
4da7cd6d17
@ -143,6 +143,10 @@ ipcMain.on(apiName.symphonyApi, (event: Electron.Event, arg: IApiArgs) => {
|
||||
memoryMonitor.setMemoryInfo(arg.memoryInfo);
|
||||
}
|
||||
break;
|
||||
case apiCmds.getConfigUrl:
|
||||
const { url } = config.getGlobalConfigFields([ 'url' ]);
|
||||
event.returnValue = url;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,6 @@ export class WindowHandler {
|
||||
isWindowsOS,
|
||||
locale: i18n.getLocale(),
|
||||
resources: i18n.loadedResources,
|
||||
origin: this.globalConfig.url,
|
||||
enableCustomTitleBar: this.isCustomTitleBar,
|
||||
isMainWindow: true,
|
||||
});
|
||||
@ -394,7 +393,8 @@ export class WindowHandler {
|
||||
}
|
||||
|
||||
// Ready to show the window
|
||||
if (!this.isAutoReload) {
|
||||
// activate the window only if it is not visible to the user
|
||||
if (!this.isAutoReload && !this.mainWindow.isVisible()) {
|
||||
this.mainWindow.show();
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ export enum apiCmds {
|
||||
isMisspelled = 'is-misspelled',
|
||||
memoryInfo = 'memory-info',
|
||||
swiftSearch = 'swift-search',
|
||||
getConfigUrl = 'get-config-url',
|
||||
}
|
||||
|
||||
export enum apiName {
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { remote } from 'electron';
|
||||
import { ipcRenderer, remote } from 'electron';
|
||||
|
||||
import {
|
||||
apiCmds,
|
||||
apiName,
|
||||
IBoundsChange,
|
||||
ILogMsg, INotificationData,
|
||||
IScreenSharingIndicator, IScreenSharingIndicatorOptions,
|
||||
@ -23,7 +24,7 @@ try {
|
||||
console.warn("Failed to initialize swift search. You'll need to include the search dependency. Contact the developers for more details");
|
||||
}
|
||||
|
||||
export default class AppBridge {
|
||||
export class AppBridge {
|
||||
|
||||
/**
|
||||
* Validates the incoming postMessage
|
||||
@ -59,7 +60,7 @@ export default class AppBridge {
|
||||
constructor() {
|
||||
// starts with corporate pod and
|
||||
// will be updated with the global config url
|
||||
this.origin = 'https://corporate.symphony.com';
|
||||
this.origin = ipcRenderer.sendSync(apiName.symphonyApi, { cmd: apiCmds.getConfigUrl });
|
||||
if (ssInstance && typeof ssInstance.setBroadcastMessage === 'function') {
|
||||
ssInstance.setBroadcastMessage(this.broadcastMessage);
|
||||
}
|
||||
@ -230,3 +231,7 @@ export default class AppBridge {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const appBridge = new AppBridge();
|
||||
|
||||
export default appBridge;
|
||||
|
@ -10,7 +10,7 @@ import { apiCmds, apiName } from '../common/api-interface';
|
||||
import { isWindowsOS } from '../common/env';
|
||||
import { i18n } from '../common/i18n-preload';
|
||||
|
||||
const includes = [].includes;
|
||||
const includes = [''].includes;
|
||||
|
||||
let nextId = 0;
|
||||
let isScreenShareEnabled = false;
|
||||
|
@ -4,7 +4,7 @@ import * as ReactDOM from 'react-dom';
|
||||
import { apiCmds, apiName } from '../common/api-interface';
|
||||
|
||||
import { i18n } from '../common/i18n-preload';
|
||||
import AppBridge from './app-bridge';
|
||||
import './app-bridge';
|
||||
import DownloadManager from './components/download-manager';
|
||||
import SnackBar from './components/snack-bar';
|
||||
import WindowsTitleBar from './components/windows-title-bar';
|
||||
@ -15,7 +15,6 @@ interface ISSFWindow extends Window {
|
||||
}
|
||||
|
||||
const ssfWindow: ISSFWindow = window;
|
||||
const appBridge = new AppBridge();
|
||||
const memoryInfoFetchInterval = 60 * 60 * 1000;
|
||||
|
||||
/**
|
||||
@ -43,11 +42,7 @@ const createAPI = () => {
|
||||
createAPI();
|
||||
|
||||
// When the window is completely loaded
|
||||
ipcRenderer.on('page-load', (_event, { locale, resources, origin, enableCustomTitleBar, isMainWindow }) => {
|
||||
// origin for postMessage targetOrigin communication
|
||||
if (origin) {
|
||||
appBridge.origin = origin;
|
||||
}
|
||||
ipcRenderer.on('page-load', (_event, { locale, resources, enableCustomTitleBar, isMainWindow }) => {
|
||||
|
||||
i18n.setResource(locale, resources);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user