mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-10 17:05:47 +00:00
Lint error fixed #126[WIP]
This commit is contained in:
@@ -3,9 +3,9 @@ const path = require('path');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
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 {dialog} = require('electron');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const electronLocalshortcut = require('electron-localshortcut');
|
const electronLocalshortcut = require('electron-localshortcut');
|
||||||
@@ -13,8 +13,8 @@ const Configstore = require('electron-config');
|
|||||||
const JsonDB = require('node-json-db');
|
const JsonDB = require('node-json-db');
|
||||||
const isDev = require('electron-is-dev');
|
const isDev = require('electron-is-dev');
|
||||||
const appMenu = require('./menu');
|
const appMenu = require('./menu');
|
||||||
const { linkIsInternal, skipImages } = require('./link-helper');
|
const {linkIsInternal, skipImages} = require('./link-helper');
|
||||||
const { appUpdater } = require('./autoupdater');
|
const {appUpdater} = require('./autoupdater');
|
||||||
|
|
||||||
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
||||||
const data = db.getData('/');
|
const data = db.getData('/');
|
||||||
@@ -68,13 +68,12 @@ function serverError(targetURL) {
|
|||||||
});
|
});
|
||||||
req.on('error', e => {
|
req.on('error', e => {
|
||||||
if (e.toString().indexOf('Error: self signed certificate') >= 0) {
|
if (e.toString().indexOf('Error: self signed certificate') >= 0) {
|
||||||
var url = targetURL.replace(/^https?:\/\//, '');
|
const url = targetURL.replace(/^https?:\/\//, '');
|
||||||
console.log('Server StatusCode:', 200);
|
console.log('Server StatusCode:', 200);
|
||||||
console.log('You are connected to:', url);
|
console.log('You are connected to:', url);
|
||||||
} else {
|
} else {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
req.end();
|
req.end();
|
||||||
} else if (data.domain) {
|
} else if (data.domain) {
|
||||||
@@ -256,27 +255,26 @@ function createMainWindow() {
|
|||||||
|
|
||||||
// For self-signed certificate
|
// For self-signed certificate
|
||||||
ipc.on('certificate-err', (e, domain) => {
|
ipc.on('certificate-err', (e, domain) => {
|
||||||
var detail = `URL: ${domain} \n Error: Self-Signed Certificate`;
|
const detail = `URL: ${domain} \n Error: Self-Signed Certificate`;
|
||||||
dialog.showMessageBox( mainWindow, {
|
dialog.showMessageBox(mainWindow, {
|
||||||
title: 'Certificate error',
|
title: 'Certificate error',
|
||||||
message: `Do you trust certificate from ${domain}?`,
|
message: `Do you trust certificate from ${domain}?`,
|
||||||
|
// eslint-disable-next-line object-shorthand
|
||||||
detail: detail,
|
detail: detail,
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
buttons: [
|
buttons: ['Yes', 'No'],
|
||||||
'Yes',
|
|
||||||
'No'
|
|
||||||
],
|
|
||||||
cancelId: 1
|
cancelId: 1
|
||||||
}, (response) => {
|
// eslint-disable-next-line object-shorthand
|
||||||
|
}, response => {
|
||||||
if (response === 0) {
|
if (response === 0) {
|
||||||
db.push("/certifiedURL", [{domain:domain}], false);
|
// eslint-disable-next-line object-shorthand
|
||||||
|
db.push('/certifiedURL', [{domain: domain}], false);
|
||||||
db.push('/domain', domain);
|
db.push('/domain', domain);
|
||||||
mainWindow.loadURL(domain);
|
mainWindow.loadURL(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
callback(true);
|
callback(true);
|
||||||
|
|||||||
@@ -6,26 +6,22 @@ const request = require('request');
|
|||||||
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
||||||
const data = db.getData('/');
|
const data = db.getData('/');
|
||||||
|
|
||||||
if(!data.certifiedURL) {
|
if (!data.certifiedURL) {
|
||||||
db.push("/certifiedURL",[]);
|
db.push('/certifiedURL', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
let URL_List = db.getData('/certifiedURL');
|
const UrlList = db.getData('/certifiedURL');
|
||||||
let URL_Length = URL_List.length;
|
const UrlLength = UrlList.length;
|
||||||
|
|
||||||
|
|
||||||
const checkURL = domain => {
|
const checkURL = domain => {
|
||||||
|
for (let i = 0; i < UrlLength; i++) {
|
||||||
for ( var i = 0; i < URL_Length; i++) {
|
if (UrlList[i].domain === domain) {
|
||||||
if (URL_List[i].domain === domain);
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
window.addDomain = function () {
|
window.addDomain = function () {
|
||||||
const el = sel => {
|
const el = sel => {
|
||||||
return document.querySelector(sel);
|
return document.querySelector(sel);
|
||||||
@@ -81,7 +77,7 @@ window.addDomain = function () {
|
|||||||
db.push('/domain', domain);
|
db.push('/domain', domain);
|
||||||
ipcRenderer.send('new-domain', domain);
|
ipcRenderer.send('new-domain', domain);
|
||||||
} else if (error.toString().indexOf('Error: self signed certificate') >= 0) {
|
} else if (error.toString().indexOf('Error: self signed certificate') >= 0) {
|
||||||
if(checkURL(domain)) {
|
if (checkURL(domain)) {
|
||||||
$el.main.innerHTML = 'Connect';
|
$el.main.innerHTML = 'Connect';
|
||||||
db.push('/domain', domain);
|
db.push('/domain', domain);
|
||||||
ipcRenderer.send('new-domain', domain);
|
ipcRenderer.send('new-domain', domain);
|
||||||
|
|||||||
@@ -20,25 +20,21 @@ window.prefDomain = function () {
|
|||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
const JsonDB = require('node-json-db');
|
const JsonDB = require('node-json-db');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
const {
|
const {app} = require('electron').remote;
|
||||||
app
|
|
||||||
} = require('electron').remote;
|
|
||||||
|
|
||||||
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
||||||
|
|
||||||
let URL_List = db.getData('/certifiedURL');
|
const UrlList = db.getData('/certifiedURL');
|
||||||
|
|
||||||
let URL_Length = URL_List.length;
|
const UrlLength = UrlList.length;
|
||||||
|
|
||||||
const checkURL = domain => {
|
const checkURL = domain => {
|
||||||
|
for (let i = 0; i < UrlLength; i++) {
|
||||||
for ( var i = 0; i < URL_Length; i++) {
|
if (UrlList[i].domain === domain) {
|
||||||
if (URL_List[i].domain === domain);
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let newDomain = document.getElementById('url').value;
|
let newDomain = document.getElementById('url').value;
|
||||||
@@ -73,7 +69,7 @@ window.prefDomain = function () {
|
|||||||
db.push('/domain', domain);
|
db.push('/domain', domain);
|
||||||
ipcRenderer.send('new-domain', domain);
|
ipcRenderer.send('new-domain', domain);
|
||||||
} else if (error.toString().indexOf('Error: self signed certificate') >= 0) {
|
} else if (error.toString().indexOf('Error: self signed certificate') >= 0) {
|
||||||
if(checkURL(domain)) {
|
if (checkURL(domain)) {
|
||||||
document.getElementById('main').innerHTML = 'Switch';
|
document.getElementById('main').innerHTML = 'Switch';
|
||||||
document.getElementById('urladded').innerHTML = 'Switched to ' + newDomain;
|
document.getElementById('urladded').innerHTML = 'Switched to ' + newDomain;
|
||||||
db.push('/domain', domain);
|
db.push('/domain', domain);
|
||||||
@@ -82,9 +78,7 @@ window.prefDomain = function () {
|
|||||||
document.getElementById('main').innerHTML = 'Switch';
|
document.getElementById('main').innerHTML = 'Switch';
|
||||||
ipcRenderer.send('certificate-err', domain);
|
ipcRenderer.send('certificate-err', domain);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.getElementById('main').innerHTML = 'Switch';
|
document.getElementById('main').innerHTML = 'Switch';
|
||||||
document.getElementById('urladded').innerHTML = 'Not a valid Zulip Server.';
|
document.getElementById('urladded').innerHTML = 'Not a valid Zulip Server.';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user