Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Migrate to electron-config
Browse files Browse the repository at this point in the history
  • Loading branch information
jwheare committed Jul 19, 2016
1 parent 770f7bd commit 16aaef0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
38 changes: 30 additions & 8 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const path = require('path');
const FS = require('fs');

const ConfigStore = require('configstore');
const Config = require('electron-config');
const Menu = require('./menu');
const Tray = electron.Tray;
const SquirrelWindows = require('./squirrel_windows');
Expand All @@ -28,14 +29,35 @@ var mainWindow = null;
var menu = null;
var appIcon = null;

const config = new ConfigStore(app.getName(), {
'host': 'https://www.irccloud.com',
'width': 1024,
'height': 768,
'zoom': 0,
'spellcheck': true,
'neverPromptIrcUrls': false
});
function setupConfig () {
let defaults = {
'host': 'https://www.irccloud.com',
'width': 1024,
'height': 768,
'zoom': 0,
'spellcheck': true,
'neverPromptIrcUrls': false
};

// Migrate from old config, remove this in time
let oldConfig = new ConfigStore(app.getName());
try {
Object.keys(defaults).concat('x', 'y').forEach(key => {
if (oldConfig.has(key)) {
defaults[key] = oldConfig.get(key);
}
});
FS.unlinkSync(oldConfig.path);
} catch (exc) {
// noop
}

return new Config({
defaults: defaults
});
}
const config = setupConfig();

const minZoom = -8;
const maxZoom = 9;

Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"main": "main.js",
"dependencies": {
"configstore": "yeoman/configstore#901a91bd1b10ddaa554d5772412352c1c55a0d73",
"electron-config": "^0.2.1",
"electron-editor-context-menu": "^1.1.1",
"electron-log": "^1.0.14",
"electron-spell-check-provider": "^1.0.0",
Expand Down

0 comments on commit 16aaef0

Please sign in to comment.