mirror of
https://github.com/dnlbauer/obsidian-dataview-autocompletion.git
synced 2026-09-10 14:15:29 +00:00
fix: error on event if suggester not initialized yet
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -3,11 +3,11 @@ import { DataviewSuggester } from "./DataviewSuggester";
|
||||
import { getAPI } from "obsidian-dataview";
|
||||
|
||||
interface DataviewAutocompleteSettings {
|
||||
// mySetting: string;
|
||||
ignoredFields: string[];
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: DataviewAutocompleteSettings = {
|
||||
// mySetting: 'default'
|
||||
ignoredFields: [],
|
||||
};
|
||||
|
||||
export default class DataviewAutocompletePlugin extends Plugin {
|
||||
@@ -20,7 +20,9 @@ export default class DataviewAutocompletePlugin extends Plugin {
|
||||
this.registerEvent(
|
||||
// @ts-ignore
|
||||
this.app.metadataCache.on("dataview:index-ready", () => {
|
||||
this.suggester.onDataviewIndexReady();
|
||||
if (this.suggester !== undefined) {
|
||||
this.suggester.onDataviewIndexReady();
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -29,7 +31,9 @@ export default class DataviewAutocompletePlugin extends Plugin {
|
||||
// @ts-ignore
|
||||
"dataview:metadata-change",
|
||||
(type: string, file: TFile, oldPath?: string) => {
|
||||
this.suggester.onDataviewMetadataChange(type, file, oldPath);
|
||||
if (this.suggester !== undefined) {
|
||||
this.suggester.onDataviewMetadataChange(type, file, oldPath);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user