mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
Merge branch 'master' into SDA-2681
This commit is contained in:
commit
2f03d802b0
@ -44,6 +44,7 @@ jest.mock('../src/app/window-handler', () => {
|
||||
createScreenSharingIndicatorWindow: jest.fn(),
|
||||
isOnline: false,
|
||||
updateVersionInfo: jest.fn(),
|
||||
isMana: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
@ -405,5 +406,15 @@ describe('main api handler', () => {
|
||||
ipcMain.send(apiName.symphonyApi, value);
|
||||
expect(spy).toBeCalledWith(...expectedValue);
|
||||
});
|
||||
|
||||
it('should call `setIsMana` correctly', () => {
|
||||
const value = {
|
||||
cmd: apiCmds.setIsMana,
|
||||
isMana: true,
|
||||
};
|
||||
expect(windowHandler.isMana).toBe(false);
|
||||
ipcMain.send(apiName.symphonyApi, value);
|
||||
expect(windowHandler.isMana).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -201,7 +201,15 @@ ipcMain.on(apiName.symphonyApi, async (event: Electron.IpcMainEvent, arg: IApiAr
|
||||
if (windowHandler.appMenu) {
|
||||
windowHandler.appMenu.buildMenu();
|
||||
}
|
||||
break;
|
||||
case apiCmds.setIsMana:
|
||||
if (typeof arg.isMana === 'boolean') {
|
||||
windowHandler.isMana = arg.isMana;
|
||||
logger.info('window-handler: isMana: ' + windowHandler.isMana);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -425,6 +425,8 @@ export class WindowHandler {
|
||||
});
|
||||
|
||||
this.mainWindow.webContents.on('did-finish-load', async () => {
|
||||
// reset to false when the client reloads
|
||||
this.isMana = false;
|
||||
logger.info(`window-handler: main window web contents finished loading!`);
|
||||
// early exit if the window has already been destroyed
|
||||
if (!this.mainWindow || !windowExists(this.mainWindow)) {
|
||||
@ -435,13 +437,6 @@ export class WindowHandler {
|
||||
}
|
||||
this.url = this.mainWindow.webContents.getURL();
|
||||
logger.info('window-handler: did-finish-load, url: ' + this.url);
|
||||
const manaPath = 'client-bff';
|
||||
if (this.url.includes(manaPath)) {
|
||||
this.isMana = true;
|
||||
} else {
|
||||
this.isMana = false;
|
||||
}
|
||||
logger.info('window-handler: isMana: ' + this.isMana);
|
||||
|
||||
// Injects custom title bar and snack bar css into the webContents
|
||||
await injectStyles(this.mainWindow, this.isCustomTitleBar);
|
||||
|
@ -669,9 +669,7 @@ export const monitorNetworkInterception = (url: string) => {
|
||||
if (!mainWindow || !windowExists(mainWindow)) {
|
||||
return;
|
||||
}
|
||||
const manaUrl: string = await mainWindow.webContents.executeJavaScript('document.location.href');
|
||||
const isMana = manaUrl && manaUrl.includes('client-bff');
|
||||
if (!isMana && windowHandler.isWebPageLoading
|
||||
if (!windowHandler.isMana && windowHandler.isWebPageLoading
|
||||
&& (details.error === 'net::ERR_INTERNET_DISCONNECTED'
|
||||
|| details.error === 'net::ERR_NETWORK_CHANGED'
|
||||
|| details.error === 'net::ERR_NAME_NOT_RESOLVED')) {
|
||||
|
@ -43,6 +43,7 @@ export enum apiCmds {
|
||||
showDownloadedItem = 'show-downloaded-item',
|
||||
clearDownloadedItems = 'clear-downloaded-items',
|
||||
restartApp = 'restart-app',
|
||||
setIsMana = 'set-is-mana',
|
||||
}
|
||||
|
||||
export enum apiName {
|
||||
@ -78,6 +79,7 @@ export interface IApiArgs {
|
||||
logName: string;
|
||||
logs: ILogs;
|
||||
cloudConfig: object;
|
||||
isMana: boolean;
|
||||
}
|
||||
|
||||
export type WindowTypes = 'screen-picker' | 'screen-sharing-indicator' | 'notification-settings';
|
||||
|
@ -51,6 +51,7 @@ createAPI();
|
||||
if (ssfWindow.ssf) {
|
||||
// New context bridge api that exposes all the methods on to window object
|
||||
contextBridge.exposeInMainWorld('manaSSF', {
|
||||
setIsMana: ssfWindow.ssf.setIsMana,
|
||||
CryptoLib: ssfWindow.ssf.CryptoLib,
|
||||
Search: ssfWindow.ssf.Search,
|
||||
Notification: ssfWindow.ssf.Notification,
|
||||
|
@ -579,6 +579,17 @@ export class SSFApi {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the client is running on mana
|
||||
* @param isMana
|
||||
*/
|
||||
public setIsMana(isMana: boolean): void {
|
||||
ipcRenderer.send(apiName.symphonyApi, {
|
||||
cmd: apiCmds.setIsMana,
|
||||
isMana,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user