Skip to content

Commit

Permalink
fix: properly merge existing settings with new
Browse files Browse the repository at this point in the history
fixes #10
  • Loading branch information
aviskase committed Nov 24, 2020
1 parent 18b697a commit ca703a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
"standard-version": "^9.0.0",
"tslib": "^2.0.3",
"typescript": "^4.0.3"
},
"dependencies": {
"deepmerge": "^4.2.2"
}
}
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deepmerge from 'deepmerge';
import { Plugin, PluginSettingTab, Setting, Vault, normalizePath, TFile, getLinkpath, ReferenceCache } from 'obsidian';

interface IndexNode {
Expand All @@ -12,7 +13,7 @@ export default class LinkIndexer extends Plugin {
onInit() {}

async onload() {
this.settings = (await this.loadData()) || new LinkIndexerSettings();
this.settings = deepmerge(new LinkIndexerSettings(), (await this.loadData()));
this.addSettingTab(new LinkIndexerSettingTab(this.app, this));

this.addCommand({
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"esModuleInterop": true,
"lib": [
"dom",
"es5",
Expand Down

0 comments on commit ca703a9

Please sign in to comment.