mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 01:54:40 +08:00
fix(config): When resetting config, use template file
This commit is contained in:
parent
3df2b1e3be
commit
84ed8faf6b
1 changed files with 12 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue