From 84ed8faf6b7e5b14035c981c3ccb044d02ebe5dc Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 31 May 2016 12:15:34 -0700 Subject: [PATCH] fix(config): When resetting config, use template file --- src/browser/config-persistence-manager.es6 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/browser/config-persistence-manager.es6 b/src/browser/config-persistence-manager.es6 index 598a42077..82920575d 100644 --- a/src/browser/config-persistence-manager.es6 +++ b/src/browser/config-persistence-manager.es6 @@ -28,12 +28,16 @@ export default class ConfigPersistenceManager { } if (!fs.existsSync(this.configFilePath)) { - const templateConfigPath = path.join(this.resourcePath, 'dot-nylas', 'config.json'); - const templateConfig = fs.readFileSync(templateConfigPath); - fs.writeFileSync(this.configFilePath, templateConfig); + this.writeTemplateConfigFile(); } } + writeTemplateConfigFile() { + const templateConfigPath = path.join(this.resourcePath, 'dot-nylas', 'config.json'); + const templateConfig = fs.readFileSync(templateConfigPath); + fs.writeFileSync(this.configFilePath, templateConfig); + } + load() { this.userWantsToPreserveErrors = false; @@ -59,8 +63,11 @@ export default class ConfigPersistenceManager { } else if (clickedIndex === 1) { this.load(); } else { - this.settings = {}; - this.emitChangeEvent(); + if (fs.existsSync(this.configFilePath)) { + fs.unlinkSync(this.configFilePath); + } + this.writeTemplateConfigFile(); + this.load(); } } }