Commit fc03a2f 1 parent 4104371 commit fc03a2f Copy full SHA for fc03a2f
File tree 1 file changed +5
-6
lines changed
src/lib/obsidian-dataview
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -5,19 +5,18 @@ import { mergeTaskParts } from "@/data/merge-task-parts";
5
5
import { parseTaskEmojis } from "@/data/parse-task-emojis" ;
6
6
7
7
export class Dataview {
8
- private constructor (
9
- private readonly plugin : Plugin ,
10
- private readonly dv : DataviewApi = getAPI ( plugin . app ) ,
11
- ) { }
8
+ private constructor ( private readonly plugin : Plugin , private readonly dv : DataviewApi ) { }
12
9
13
10
/** IMPORTANT: Must be called from within `onLayoutReady` callback, otherwise the plugin will freeze! */
14
11
public static async getReady ( plugin : Plugin ) : Promise < Dataview > {
15
12
return new Promise < Dataview > ( ( resolve , reject ) => {
16
13
if ( ! isPluginEnabled ( plugin . app ) ) {
17
14
reject ( new Error ( "obsidian-dataview is not installed and/or enabled" ) ) ;
18
15
} else {
19
- const api : DataviewApi = getAPI ( plugin . app ) ;
20
- if ( api ?. index . initialized ) {
16
+ const api = getAPI ( plugin . app ) ;
17
+ if ( ! api ) {
18
+ reject ( new Error ( "obsidian-dataview could not be loaded" ) ) ;
19
+ } else if ( api . index . initialized ) {
21
20
resolve ( new Dataview ( plugin , api ) ) ;
22
21
} else {
23
22
plugin . registerEvent (
You can’t perform that action at this time.
0 commit comments