Skip to content

Commit

Permalink
Catch exception parsing domains.json
Browse files Browse the repository at this point in the history
  • Loading branch information
smpallen99 committed Jun 22, 2018
1 parent cdd77b0 commit 1183906
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
10 changes: 8 additions & 2 deletions app/main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path');

// const { app, shell, BrowserWindow, Menu } = require('electron');
const { app, BrowserWindow, Menu } = require('electron');
const { app, shell, BrowserWindow, Menu } = require('electron');

const fs = require('fs-extra');

Expand Down Expand Up @@ -120,7 +120,13 @@ class AppMenu {
{
label: `${appName + ' Desktop-'} v${app.getVersion()}`,
enabled: false
}];
}, {
label: 'Show App Data',
click() {
shell.openItem(app.getPath('userData'));
}
}
];
}

// getHelpSubmenu() {
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "infinityone",
"productName": "InfinityOne",
"version": "0.9.2",
"version": "1.0.0-rc",
"description": "Infinity One Desktop App",
"license": "Apache-2.0",
"copyright": "E-MetroTel Global Inc.",
Expand Down
40 changes: 23 additions & 17 deletions app/renderer/js/utils/domain-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DomainUtil {
}

this.reloadDB();

// Migrate from old schema
if (this.db.getData('/').domain) {
this.addDomain({
Expand Down Expand Up @@ -192,24 +193,29 @@ class DomainUtil {
return new Promise((resolve, reject) => {
request(serverSettingsUrl, (error, response) => {
if (!error && response.statusCode === 200) {
const data = JSON.parse(response.body);
if (data.hasOwnProperty('realm_uri')) {
let realmIcon;

if (data.realm_icon) {
realmIcon = data.realm_icon;
} else {
realmIcon = defaultIconUrl;
}
try {
const data = JSON.parse(response.body);
if (data.hasOwnProperty('realm_uri')) {
let realmIcon;

resolve({
// Some InfinityOne Servers use absolute URL for server icon whereas others use relative URL
// Following check handles both the cases
icon: realmIcon.startsWith('/') ? data.realm_uri + realmIcon : realmIcon,
iconUrl: realmIcon,
url: data.realm_uri,
alias: data.realm_name
});
if (data.realm_icon) {
realmIcon = data.realm_icon;
} else {
realmIcon = defaultIconUrl;
}

resolve({
// Some InfinityOne Servers use absolute URL for server icon whereas others use relative URL
// Following check handles both the cases
icon: realmIcon.startsWith('/') ? data.realm_uri + realmIcon : realmIcon,
iconUrl: realmIcon,
url: data.realm_uri,
alias: data.realm_name
});
}
}
catch(err) {
reject('Infinity One server invalid response');
}
} else {
reject('Infinity One server invalid version.');
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "infinityone",
"productName": "InfinityOne",
"version": "0.9.2",
"version": "1.0.0-rc",
"main": "./app/main",
"description": "Infinity One Desktop App",
"license": "Apache-2.0",
Expand Down Expand Up @@ -115,7 +115,12 @@
"electron-app",
"electron",
"Desktop app",
"InstantMessaging"
"InstantMessaging",
"WebRTC",
"E-MetroTel",
"Unified Communications",
"Collaboration",
"Telecommunications"
],
"devDependencies": {
"assert": "1.4.1",
Expand Down

0 comments on commit 1183906

Please sign in to comment.