ELECTRON-967 (Remove auto retry logic and add manual retry) (#636)

* ELECTRON-967 - Remove auto retry logic and add manual retry

* ELECTRON-967 - Remove quit button and update display text
This commit is contained in:
Kiran Niranjan
2019-05-03 20:57:48 +05:30
committed by Vishwas Shashidhar
parent 3884a2f01c
commit 25a8e1707b
12 changed files with 31 additions and 77 deletions

View File

@@ -26,8 +26,7 @@ const cmds = keyMirror({
setLocale: null,
keyPress: null,
openScreenSharingIndicator: null,
cancelNetworkStatusCheck: null,
quitWindow: null,
reloadWindow: null,
});
module.exports = {

View File

@@ -5,7 +5,6 @@
* from the renderer process.
*/
const electron = require('electron');
const app = electron.app;
const windowMgr = require('./windowMgr.js');
const log = require('./log.js');
@@ -191,11 +190,8 @@ electron.ipcMain.on(apiName, (event, arg) => {
openScreenSharingIndicator(event.sender, arg.displayId, arg.id);
}
break;
case apiCmds.cancelNetworkStatusCheck:
windowMgr.cancelNetworkStatusCheck();
break;
case apiCmds.quitWindow:
app.quit();
case apiCmds.reloadWindow:
windowMgr.reloadWindow();
break;
default:
}
@@ -207,4 +203,4 @@ module.exports = {
shouldCheckValidWindow: function(shouldCheck) {
checkValidWindow = shouldCheck;
}
};
};

View File

@@ -109,12 +109,11 @@ const errorContent = (data) => {
<div class="main-message">
<p class="NetworkError-header">${data["Problem connecting to Symphony"] || "Problem connecting to Symphony"}</p>
<p id="NetworkError-reason">
${data["Looks like you are not connected to the Internet. We'll try to reconnect automatically."]
|| "Looks like you are not connected to the Internet. We'll try to reconnect automatically."}
${data["Looks like you are not connected to the Internet."]
|| "Looks like you are not connected to the Internet."}
</p>
<div id="error-code" class="NetworkError-error-code">ERR_INTERNET_DISCONNECTED</div>
<button id="cancel-retry-button" class="NetworkError-button">${data["Cancel Retry"] || "Cancel Retry"}</button>
<button id="quit-button" class="NetworkError-button">${data["Quit Symphony"] || "Quit Symphony"}</button>
<button id="retry-button" class="NetworkError-button">${data.Retry || "Retry"}</button>
</div>
</div>
</div>`);
@@ -123,4 +122,4 @@ const errorContent = (data) => {
module.exports = {
errorContent,
};
};

View File

@@ -20,22 +20,15 @@ class NetworkError {
errorContent.getElementById('error-code').innerText = error || "UNKNOWN_ERROR";
// Add event listeners for buttons
const cancelRetryButton = errorContent.getElementById('cancel-retry-button');
const cancelRetry = () => {
const retryButton = errorContent.getElementById('retry-button');
const retry = () => {
retryButton.classList.add('disabled');
retryButton.removeEventListener('click', retry);
ipcRenderer.send(apiName, {
cmd: apiCmds.cancelNetworkStatusCheck
cmd: apiCmds.reloadWindow
});
cancelRetryButton.classList.add('disabled');
cancelRetryButton.removeEventListener('click', cancelRetry);
};
cancelRetryButton.addEventListener('click', cancelRetry);
const quitButton = errorContent.getElementById('quit-button');
quitButton.addEventListener('click', () => {
ipcRenderer.send(apiName, {
cmd: apiCmds.quitWindow
});
});
retryButton.addEventListener('click', retry);
const mainFrame = errorContent.getElementById('main-frame');
document.body.appendChild(mainFrame);

View File

@@ -10,7 +10,6 @@ const path = require('path');
const nodeURL = require('url');
const querystring = require('querystring');
const filesize = require('filesize');
const fetch = require('electron-fetch').default;
const { getTemplate, getMinimizeOnClose, getTitleBarStyle } = require('./menus/menuTemplate.js');
const isInDisplayBounds = require('./utils/isInDisplayBounds.js');
@@ -48,8 +47,6 @@ let isAutoReload = false;
let devToolsEnabled = true;
let isCustomTitleBarEnabled = true;
let titleBarStyles;
let networkStatusCheckIntervalId;
const networkStatusCheckInterval = 5000;
const KeyCodes = {
Esc: 27,
@@ -352,7 +349,6 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
const message = i18n.getMessageFor('NetworkError');
mainWindow.webContents.insertCSS(fs.readFileSync(path.join(__dirname, '/networkError/style.css'), 'utf8').toString());
mainWindow.webContents.send('network-error', { message, error: lastLoadFailError || "PAGE_STOPPED_LOADING"});
isSymphonyReachable(mainWindow, config.url);
}
}).catch((error) => {
log.send(logLevels.ERROR, `Could not read document.location error: ${error}`);
@@ -1315,41 +1311,13 @@ const logBrowserWindowEvents = (browserWindow, windowName) => {
};
/**
* Validates the network by fetching the pod url
* every 5sec, on active reloads the given window
*
* @param window
* @param url
* Loads the main window with the global config url
*/
const isSymphonyReachable = (window, url) => {
if (networkStatusCheckIntervalId) {
const reloadWindow = () => {
if (!(mainWindow && typeof mainWindow.isDestroyed === 'function' && !mainWindow.isDestroyed())) {
return;
}
networkStatusCheckIntervalId = setInterval(() => {
fetch(config.url).then((rsp) => {
if (rsp.status === 200 && isOnline) {
window.loadURL(url);
if (networkStatusCheckIntervalId) {
clearInterval(networkStatusCheckIntervalId);
networkStatusCheckIntervalId = null;
}
} else {
log.send(logLevels.INFO, `Symphony down! statusCode: ${rsp.status} is online: ${isOnline}`);
}
}).catch((error) => {
log.send(logLevels.INFO, `Network status check: No active network connection ${error}`);
});
}, networkStatusCheckInterval);
};
/**
* Clears the network status check interval
*/
const cancelNetworkStatusCheck = () => {
if (networkStatusCheckIntervalId) {
clearInterval(networkStatusCheckIntervalId);
networkStatusCheckIntervalId = null;
}
mainWindow.loadURL(config.url);
};
module.exports = {
@@ -1370,5 +1338,5 @@ module.exports = {
getIsOnline: getIsOnline,
getSpellchecker: getSpellchecker,
isMisspelled: isMisspelled,
cancelNetworkStatusCheck: cancelNetworkStatusCheck,
reloadWindow: reloadWindow
};

View File

@@ -70,8 +70,8 @@
"Network connectivity has been lost. Check your internet connection.": "Network connectivity has been lost. Check your internet connection.",
"NetworkError": {
"Problem connecting to Symphony": "Problem connecting to Symphony",
"Looks like you are not connected to the Internet. We'll try to reconnect automatically.": "Looks like you are not connected to the Internet. We'll try to reconnect automatically.",
"Cancel Retry": "Cancel Retry",
"Looks like you are not connected to the Internet.": "Looks like you are not connected to the Internet.",
"Retry": "Retry",
"Quit Symphony": "Quit Symphony"
},
"No crashes available to share": "No crashes available to share",

View File

@@ -70,8 +70,8 @@
"Network connectivity has been lost. Check your internet connection.": "Network connectivity has been lost. Check your internet connection.",
"NetworkError": {
"Problem connecting to Symphony": "Problem connecting to Symphony",
"Looks like you are not connected to the Internet. We'll try to reconnect automatically.": "Looks like you are not connected to the Internet. We'll try to reconnect automatically.",
"Cancel Retry": "Cancel Retry",
"Looks like you are not connected to the Internet.": "Looks like you are not connected to the Internet.",
"Retry": "Retry",
"Quit Symphony": "Quit Symphony"
},
"No crashes available to share": "No crashes available to share",

View File

@@ -70,8 +70,8 @@
"Network connectivity has been lost. Check your internet connection.": "La connectivité a été perdue. Vérifiez votre connection à l'internet.",
"NetworkError": {
"Problem connecting to Symphony": "Problème de connexion à Symphony",
"Looks like you are not connected to the Internet. We'll try to reconnect automatically.": "On dirait que vous n'êtes pas connecté à Internet. Nous allons essayer de vous reconnecter automatiquement.",
"Cancel Retry": "Annuler réessayer",
"Looks like you are not connected to the Internet.": "On dirait que vous n'êtes pas connecté à Internet.",
"Retry": "Réessayez",
"Quit Symphony": "Quitter Symphony"
},
"No crashes available to share": "Pas de crash à partager",

View File

@@ -70,8 +70,8 @@
"Network connectivity has been lost. Check your internet connection.": "La connectivité a été perdue. Vérifiez votre connection à l'internet.",
"NetworkError": {
"Problem connecting to Symphony": "Problème de connexion à Symphony",
"Looks like you are not connected to the Internet. We'll try to reconnect automatically.": "On dirait que vous n'êtes pas connecté à Internet. Nous allons essayer de vous reconnecter automatiquement.",
"Cancel Retry": "Annuler réessayer",
"Looks like you are not connected to the Internet.": "On dirait que vous n'êtes pas connecté à Internet.",
"Retry": "Réessayez",
"Quit Symphony": "Quitter Symphony"
},
"No crashes available to share": "Pas de crash à partager",

View File

@@ -70,8 +70,8 @@
"Network connectivity has been lost. Check your internet connection.": "ネットワーク接続が失われました。インターネット接続を確認してください。",
"NetworkError": {
"Problem connecting to Symphony": "Symphonyへの接続に関する問題",
"Looks like you are not connected to the Internet. We'll try to reconnect automatically.": "インターネットに接続していないようです。 自動的に再接続します。",
"Cancel Retry": "再試行をキャンセル",
"Looks like you are not connected to the Internet.": "インターネットに接続していないようです。",
"Retry": "再試行を",
"Quit Symphony": "Symphonyを終了します"
},
"No crashes available to share": "共有できるクラッシュはありません",

View File

@@ -70,8 +70,8 @@
"Network connectivity has been lost. Check your internet connection.": "ネットワーク接続が失われました。インターネット接続を確認してください。",
"NetworkError": {
"Problem connecting to Symphony": "Symphonyへの接続に関する問題",
"Looks like you are not connected to the Internet. We'll try to reconnect automatically.": "インターネットに接続していないようです。 自動的に再接続します。",
"Cancel Retry": "再試行をキャンセル",
"Looks like you are not connected to the Internet.": "インターネットに接続していないようです。",
"Retry": "再試行を",
"Quit Symphony": "Symphonyを終了します"
},
"No crashes available to share": "共有できるクラッシュはありません",

View File

@@ -113,7 +113,6 @@
"async.map": "0.5.2",
"async.mapseries": "0.5.2",
"electron-dl": "1.12.0",
"electron-fetch": "1.3.0",
"electron-log": "2.2.17",
"electron-spellchecker": "git+https://github.com/symphonyoss/electron-spellchecker.git#v2.0.1",
"ffi": "git+https://github.com/symphonyoss/node-ffi.git#v1.2.8",