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:
@@ -3,11 +3,11 @@ import { DataviewSuggester } from "./DataviewSuggester";
|
|||||||
import { getAPI } from "obsidian-dataview";
|
import { getAPI } from "obsidian-dataview";
|
||||||
|
|
||||||
interface DataviewAutocompleteSettings {
|
interface DataviewAutocompleteSettings {
|
||||||
// mySetting: string;
|
ignoredFields: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: DataviewAutocompleteSettings = {
|
const DEFAULT_SETTINGS: DataviewAutocompleteSettings = {
|
||||||
// mySetting: 'default'
|
ignoredFields: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class DataviewAutocompletePlugin extends Plugin {
|
export default class DataviewAutocompletePlugin extends Plugin {
|
||||||
@@ -20,7 +20,9 @@ export default class DataviewAutocompletePlugin extends Plugin {
|
|||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.app.metadataCache.on("dataview:index-ready", () => {
|
this.app.metadataCache.on("dataview:index-ready", () => {
|
||||||
|
if (this.suggester !== undefined) {
|
||||||
this.suggester.onDataviewIndexReady();
|
this.suggester.onDataviewIndexReady();
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -29,7 +31,9 @@ export default class DataviewAutocompletePlugin extends Plugin {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
"dataview:metadata-change",
|
"dataview:metadata-change",
|
||||||
(type: string, file: TFile, oldPath?: string) => {
|
(type: string, file: TFile, oldPath?: string) => {
|
||||||
|
if (this.suggester !== undefined) {
|
||||||
this.suggester.onDataviewMetadataChange(type, file, oldPath);
|
this.suggester.onDataviewMetadataChange(type, file, oldPath);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user