From 9e50ffa4722e98e0edf65b6a302c3b5ace946f9a Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Tue, 23 Jun 2020 18:33:11 +0530 Subject: [PATCH] fix: SDA-2151: fix network request url reload (#1024) * SDA-2151: fix network request url reload * SDA-2151: add documentation for new parameter --- src/app/window-handler.ts | 4 ++-- src/app/window-utils.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index fa09c256..7f0cdb46 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -306,7 +306,7 @@ export class WindowHandler { } // monitors network connection and // displays error banner on failure - monitorNetworkInterception(); + monitorNetworkInterception(this.url || this.userConfig.url || this.globalConfig.url); }); this.mainWindow.webContents.on('did-finish-load', async () => { @@ -358,7 +358,7 @@ export class WindowHandler { if (this.mainWindow && windowExists(this.mainWindow)) { this.mainWindow.webContents.insertCSS(fs.readFileSync(path.join(__dirname, '..', '/renderer/styles/network-error.css'), 'utf8').toString()); this.mainWindow.webContents.send('network-error', {error: this.loadFailError}); - isSymphonyReachable(this.mainWindow); + isSymphonyReachable(this.mainWindow, this.url || this.userConfig.url || this.globalConfig.url); } } } catch (error) { diff --git a/src/app/window-utils.ts b/src/app/window-utils.ts index a467490b..d439ba74 100644 --- a/src/app/window-utils.ts +++ b/src/app/window-utils.ts @@ -32,7 +32,6 @@ enum styleNames { } const checkValidWindow = true; -const { url: configUrl } = config.getGlobalConfigFields([ 'url' ]); const { ctWhitelist } = config.getConfigFields([ 'ctWhitelist' ]); // Network status check variables @@ -518,8 +517,9 @@ export const handleCertificateProxyVerification = ( * every 10sec, on active reloads the given window * * @param window {ICustomBrowserWindow} + * @param url Pod URL to load */ -export const isSymphonyReachable = (window: ICustomBrowserWindow | null) => { +export const isSymphonyReachable = (window: ICustomBrowserWindow | null, url: string) => { if (networkStatusCheckIntervalId) { return; } @@ -527,7 +527,7 @@ export const isSymphonyReachable = (window: ICustomBrowserWindow | null) => { return; } networkStatusCheckIntervalId = setInterval(() => { - const { hostname, protocol } = parse(configUrl); + const { hostname, protocol } = parse(url); if (!hostname || !protocol) { return; } @@ -536,7 +536,7 @@ export const isSymphonyReachable = (window: ICustomBrowserWindow | null) => { fetch(podUrl, { method: 'GET' }).then((rsp) => { if (rsp.status === 200 && windowHandler.isOnline) { logger.info(`window-utils: pod ${podUrl} is reachable, loading main window!`); - window.loadURL(configUrl); + window.loadURL(url); if (networkStatusCheckIntervalId) { clearInterval(networkStatusCheckIntervalId); networkStatusCheckIntervalId = null; @@ -639,12 +639,12 @@ export const updateFeaturesForCloudConfig = async (): Promise => { /** * Monitors network requests and displays red banner on failure + * @param url: Pod URL to be loaded after network is active again */ -export const monitorNetworkInterception = () => { +export const monitorNetworkInterception = (url: string) => { if (isNetworkMonitorInitialized) { return; } - const { url } = config.getGlobalConfigFields( [ 'url' ] ); const { hostname, protocol } = parse(url); if (!hostname || !protocol) {