mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-03 05:23:17 +00:00
Merge pull request #115 from jajodiaraghav/offline
Display an error message if internet not working.
This commit is contained in:
@@ -5,6 +5,7 @@ const os = require('os');
|
|||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const {app} = require('electron');
|
const {app} = require('electron');
|
||||||
const ipc = require('electron').ipcMain;
|
const ipc = require('electron').ipcMain;
|
||||||
|
const {dialog} = require('electron');
|
||||||
const electronLocalshortcut = require('electron-localshortcut');
|
const electronLocalshortcut = require('electron-localshortcut');
|
||||||
const Configstore = require('configstore');
|
const Configstore = require('configstore');
|
||||||
const JsonDB = require('node-json-db');
|
const JsonDB = require('node-json-db');
|
||||||
@@ -55,6 +56,32 @@ const targetURL = function () {
|
|||||||
return data.domain;
|
return data.domain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function checkConnectivity() {
|
||||||
|
return dialog.showMessageBox({
|
||||||
|
title: 'Internet connection problem',
|
||||||
|
message: 'No internet available! Try again?',
|
||||||
|
type: 'warning',
|
||||||
|
buttons: ['Try again', 'Close'],
|
||||||
|
defaultId: 0
|
||||||
|
}, index => {
|
||||||
|
if (index === 0) {
|
||||||
|
mainWindow.webContents.reload();
|
||||||
|
}
|
||||||
|
if (index === 1) {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkConnection() {
|
||||||
|
mainWindow.webContents.on('did-fail-load', (event, errorCode, errorDescription, validatedURL) => {
|
||||||
|
if (errorDescription === 'ERR_INTERNET_DISCONNECTED' || errorDescription === 'ERR_PROXY_CONNECTION_FAILED') {
|
||||||
|
console.log('Error Description:' + errorDescription);
|
||||||
|
checkConnectivity();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const isAlreadyRunning = app.makeSingleInstance(() => {
|
const isAlreadyRunning = app.makeSingleInstance(() => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
if (mainWindow.isMinimized()) {
|
if (mainWindow.isMinimized()) {
|
||||||
@@ -87,8 +114,8 @@ const iconPath = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onClosed() {
|
function onClosed() {
|
||||||
// dereference the window
|
// Dereference the window
|
||||||
// for multiple windows store them in an array
|
// For multiple windows, store them in an array
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,10 +258,11 @@ app.on('ready', () => {
|
|||||||
page.once('did-frame-finish-load', () => {
|
page.once('did-frame-finish-load', () => {
|
||||||
const checkOS = isWindowsOrmacOS();
|
const checkOS = isWindowsOrmacOS();
|
||||||
if (checkOS && !isDev) {
|
if (checkOS && !isDev) {
|
||||||
// Initate auto-updates on macOs and windows
|
// Initate auto-updates on MacOS and Windows
|
||||||
appUpdater();
|
appUpdater();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
checkConnection();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('will-quit', () => {
|
app.on('will-quit', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user