fix: SDA-2151: fix network request url reload (#1024)

* SDA-2151: fix network request url reload

* SDA-2151: add documentation for new parameter
This commit is contained in:
Vishwas Shashidhar 2020-06-23 18:33:11 +05:30 committed by GitHub
parent b1bcbef11a
commit 9e50ffa472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -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) {

View File

@ -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<void> => {
/**
* 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) {