ELECTRON-1389 - Fix snack bar issue on Windows & Fix RTC pop-out issue (#771)

This commit is contained in:
Kiran Niranjan 2019-08-28 12:14:28 +05:30 committed by Vishwas Shashidhar
parent 2d62b3de51
commit b2db06dea8
5 changed files with 29 additions and 27 deletions

View File

@ -3,7 +3,7 @@
"productName": "Symphony",
"version": "5.0.0",
"clientVersion": "2.0.1",
"buildNumber":"",
"buildNumber": "",
"searchAPIVersion": "1.55.3",
"description": "Symphony desktop app (Foundation ODP)",
"author": "Symphony OSS <help@finos.org>",

View File

@ -78,12 +78,12 @@ export const handleChildWindow = (webContents: WebContents): void => {
logger.info(`child-window-handler: main window url: ${mainWinUrlData.subdomain}.${mainWinUrlData.domain}.${mainWinUrlData.tld}`);
const emptyUrlString = 'about:blank';
const emptyUrlString = [ 'about:blank', 'about:blank#blocked' ];
const dispositionWhitelist = ['new-window', 'foreground-tab'];
// only allow window.open to succeed is if coming from same host,
// otherwise open in default browser.
if ((newWinDomainName === mainWinDomainName || newWinUrl === emptyUrlString)
if ((newWinDomainName === mainWinDomainName || emptyUrlString.includes(newWinUrl))
&& frameName !== ''
&& dispositionWhitelist.includes(disposition)) {

View File

@ -46,14 +46,11 @@ const saveWindowSettings = async (): Promise<void> => {
};
const windowMaximized = async (args: string | undefined): Promise<void> => {
const windowMaximized = async (): Promise<void> => {
const browserWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
if (browserWindow && windowExists(browserWindow)) {
const isMaximized = browserWindow.isMaximized();
const isFullScreen = browserWindow.isFullScreen();
if (args && typeof args === 'string') {
browserWindow.webContents.send(isFullScreen ? 'window-enter-full-screen' : 'window-leave-full-screen');
}
if (browserWindow.winName === apiName.mainWindowName) {
const { mainWinPos } = config.getUserConfigFields([ 'mainWinPos' ]);
await config.updateUserConfig({ mainWinPos: { ...mainWinPos, ...{ isMaximized, isFullScreen } } });
@ -61,9 +58,9 @@ const windowMaximized = async (args: string | undefined): Promise<void> => {
}
};
const throttledWindowChanges = throttle(async (args) => {
const throttledWindowChanges = throttle(async () => {
await saveWindowSettings();
await windowMaximized(args);
await windowMaximized();
notification.moveNotificationToTop();
}, 1000);
@ -205,10 +202,10 @@ export const monitorWindowActions = (window: BrowserWindow): void => {
window.on(event, throttledWindowChanges);
}
});
window.on('enter-full-screen', throttledWindowChanges.bind(null, 'enter-full-screen'));
window.on('enter-full-screen', throttledWindowChanges);
window.on('maximize', throttledWindowChanges);
window.on('leave-full-screen', throttledWindowChanges.bind(null,'leave-full-screen'));
window.on('leave-full-screen', throttledWindowChanges);
window.on('unmaximize', throttledWindowChanges);
if ((window as ICustomBrowserWindow).winName === apiName.mainWindowName) {

View File

@ -1,4 +1,4 @@
import { ipcRenderer } from 'electron';
import { remote } from 'electron';
import Timer = NodeJS.Timer;
import { i18n } from '../../common/i18n-preload';
@ -6,29 +6,34 @@ import { i18n } from '../../common/i18n-preload';
const SNACKBAR_NAMESPACE = 'SnackBar';
export default class SnackBar {
private snackBarTimer: Timer | undefined;
private domParser: DOMParser;
private readonly body: HTMLCollectionOf<Element>;
private readonly snackBar: HTMLElement | null;
private readonly eventHandlers = {
onShowSnackBar: () => this.showSnackBar(),
onRemoveSnackBar: () => this.removeSnackBar(),
};
private snackBarTimer: Timer | undefined;
private domParser: DOMParser | undefined;
private body: HTMLCollectionOf<Element> | undefined;
private snackBar: HTMLElement | null = null;
constructor() {
this.body = document.getElementsByTagName('body');
this.domParser = new DOMParser();
const snackBar = this.domParser.parseFromString(this.render(), 'text/html');
this.snackBar = snackBar.getElementById('snack-bar');
const browserWindow = remote.getCurrentWindow();
if (browserWindow && typeof browserWindow.isDestroyed === 'function' && !browserWindow.isDestroyed()) {
browserWindow.on('enter-full-screen', this.eventHandlers.onShowSnackBar);
browserWindow.on('leave-full-screen', this.eventHandlers.onRemoveSnackBar);
}
}
/**
* initializes the event listeners
*/
public initSnackBar(): void {
this.showSnackBar = this.showSnackBar.bind(this);
this.removeSnackBar = this.removeSnackBar.bind(this);
this.body = document.getElementsByTagName('body');
ipcRenderer.on('window-enter-full-screen', this.showSnackBar);
ipcRenderer.on('window-leave-full-screen', this.removeSnackBar);
this.domParser = new DOMParser();
const snackBar = this.domParser.parseFromString(this.render(), 'text/html');
this.snackBar = snackBar.getElementById('snack-bar');
}
/**
@ -40,7 +45,7 @@ export default class SnackBar {
this.body[ 0 ].appendChild(this.snackBar);
this.snackBar.classList.add('SnackBar-show');
this.snackBarTimer = setTimeout(() => {
if (this.snackBar) {
if (this.snackBar && this.body) {
if (document.getElementById('snack-bar')) {
this.body[ 0 ].removeChild(this.snackBar);
}

View File

@ -17,6 +17,7 @@ interface ISSFWindow extends Window {
const ssfWindow: ISSFWindow = window;
const memoryInfoFetchInterval = 60 * 60 * 1000;
const snackBar = new SnackBar();
/**
* creates API exposed from electron.
@ -68,7 +69,6 @@ ipcRenderer.on('page-load', (_event, { locale, resources, enableCustomTitleBar,
});
// injects snack bar
const snackBar = new SnackBar();
snackBar.initSnackBar();
// injects download manager contents