mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
fix(config): When resetting config, use template file
This commit is contained in:
parent
3b42b2d03b
commit
cabc052c18
1 changed files with 12 additions and 5 deletions
|
@ -28,11 +28,15 @@ export default class ConfigPersistenceManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(this.configFilePath)) {
|
if (!fs.existsSync(this.configFilePath)) {
|
||||||
|
this.writeTemplateConfigFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeTemplateConfigFile() {
|
||||||
const templateConfigPath = path.join(this.resourcePath, 'dot-nylas', 'config.json');
|
const templateConfigPath = path.join(this.resourcePath, 'dot-nylas', 'config.json');
|
||||||
const templateConfig = fs.readFileSync(templateConfigPath);
|
const templateConfig = fs.readFileSync(templateConfigPath);
|
||||||
fs.writeFileSync(this.configFilePath, templateConfig);
|
fs.writeFileSync(this.configFilePath, templateConfig);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
this.userWantsToPreserveErrors = false;
|
this.userWantsToPreserveErrors = false;
|
||||||
|
@ -59,8 +63,11 @@ export default class ConfigPersistenceManager {
|
||||||
} else if (clickedIndex === 1) {
|
} else if (clickedIndex === 1) {
|
||||||
this.load();
|
this.load();
|
||||||
} else {
|
} else {
|
||||||
this.settings = {};
|
if (fs.existsSync(this.configFilePath)) {
|
||||||
this.emitChangeEvent();
|
fs.unlinkSync(this.configFilePath);
|
||||||
|
}
|
||||||
|
this.writeTemplateConfigFile();
|
||||||
|
this.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue