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