Skip to content

Commit

Permalink
Fix the overwrite of DEFAULT_SETTINGS
Browse files Browse the repository at this point in the history
  • Loading branch information
Diomede committed May 23, 2021
1 parent 7198de1 commit 83a5321
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class LiquidTemplates extends Plugin {
};

async loadSettings(): Promise<void> {
this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData());
this.settings = Object.assign({ ...DEFAULT_SETTINGS }, await this.loadData());
}

async saveSettings(): Promise<void> {
Expand Down
15 changes: 8 additions & 7 deletions settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { get, isEmpty } from "lodash";
import { App, PluginSettingTab, Setting } from "obsidian";
import LiquidTemplates from "./main";

Expand Down Expand Up @@ -40,9 +41,9 @@ export class LiquidTemplatesSettingsTab extends PluginSettingTab {
.addText((text) =>
text
.setPlaceholder(DEFAULT_SETTINGS.templatesFolder)
.setValue(this.plugin.settings.templatesFolder)
.setValue(this.plugin.settings.templatesFolder || DEFAULT_SETTINGS.templatesFolder)
.onChange(async (value) => {
this.plugin.settings.templatesFolder = value || DEFAULT_SETTINGS.templatesFolder;
this.plugin.settings.templatesFolder = value;
await this.plugin.saveSettings();
})
);
Expand All @@ -52,7 +53,7 @@ export class LiquidTemplatesSettingsTab extends PluginSettingTab {
.setDesc('Name of the folders you want to exclude from the autosuggest menu, relative to the "Templates folder" above. Comma separated values. (useful if you have a "common" or "partial" folder where you store all the partial templates)')
.addText((text) =>
text
.setValue(this.plugin.settings.excludeFolders)
.setValue(this.plugin.settings.excludeFolders || DEFAULT_SETTINGS.excludeFolders)
.onChange(async (value) => {
this.plugin.settings.excludeFolders = value;
await this.plugin.saveSettings();
Expand All @@ -65,9 +66,9 @@ export class LiquidTemplatesSettingsTab extends PluginSettingTab {
.addText((text) =>
text
.setPlaceholder(DEFAULT_SETTINGS.dateFormat)
.setValue(this.plugin.settings.dateFormat)
.setValue(this.plugin.settings.dateFormat || DEFAULT_SETTINGS.dateFormat)
.onChange(async (value) => {
this.plugin.settings.dateFormat = value || DEFAULT_SETTINGS.dateFormat;
this.plugin.settings.dateFormat = value;
await this.plugin.saveSettings();
})
);
Expand All @@ -78,9 +79,9 @@ export class LiquidTemplatesSettingsTab extends PluginSettingTab {
.addText((text) =>
text
.setPlaceholder(DEFAULT_SETTINGS.timeFormat)
.setValue(this.plugin.settings.timeFormat)
.setValue(this.plugin.settings.timeFormat || DEFAULT_SETTINGS.timeFormat)
.onChange(async (value) => {
this.plugin.settings.timeFormat = value || DEFAULT_SETTINGS.timeFormat;
this.plugin.settings.timeFormat = value;
await this.plugin.saveSettings();
})
);
Expand Down

0 comments on commit 83a5321

Please sign in to comment.