Skip to content

Commit

Permalink
Merge pull request #990 from RocketChat/fix/servers.json
Browse files Browse the repository at this point in the history
[FIX] Speed up servers.json loading
  • Loading branch information
tassoevan authored Nov 17, 2018
2 parents 864e453 + 5d13d0c commit 8edfe34
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/scripts/servers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* globals $ */

import jetpack from 'fs-jetpack';
import { EventEmitter } from 'events';
import { remote, ipcRenderer } from 'electron';
Expand Down Expand Up @@ -77,8 +75,11 @@ class Servers extends EventEmitter {

// Load server info from server config file
if (Object.keys(hosts).length === 0) {
const path = jetpack.find(remote.app.getPath('userData'), { matching: 'servers.json' })[0] ||
jetpack.find(jetpack.path(remote.app.getAppPath(), '..'), { matching: 'servers.json' })[0];
const { app } = remote;
const userDir = jetpack.cwd(app.getPath('userData'));
const appDir = jetpack.cwd(jetpack.path(app.getAppPath(), app.getAppPath().endsWith('.asar') ? '..' : '.'));
const path = userDir.find({ matching: 'servers.json', recursive: false })[0] ||
appDir.find({ matching: 'servers.json', recursive: false })[0];

if (path) {
const pathToServerJson = jetpack.path(path);
Expand Down

0 comments on commit 8edfe34

Please sign in to comment.