Skip to content

Commit 444e3cd

Browse files
author
Alexander Weichart
committed
fixed: post installation bugs
1 parent b024788 commit 444e3cd

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default class Graph3dPlugin extends Plugin {
1414
// States
1515
public settingsState: State<GraphSettings>;
1616
public openFileState: State<string | undefined> = new State(undefined);
17-
private cacheIsReady: State<boolean> = new State(false);
17+
private cacheIsReady: State<boolean> = new State(
18+
this.app.metadataCache.resolvedLinks !== undefined
19+
);
1820

1921
// Other properties
2022
public globalGraph: Graph;
@@ -48,6 +50,9 @@ export default class Graph3dPlugin extends Plugin {
4850
const settings = await this.loadSettings();
4951
this.settingsState = new State<GraphSettings>(settings);
5052
this.theme = new ObsidianTheme(this.app.workspace.containerEl);
53+
this.cacheIsReady.value =
54+
this.app.metadataCache.resolvedLinks !== undefined;
55+
this.onGraphCacheChanged();
5156
}
5257

5358
private initListeners() {
@@ -106,6 +111,7 @@ export default class Graph3dPlugin extends Plugin {
106111
}
107112

108113
private onGraphCacheReady = () => {
114+
console.log("Graph cache is ready");
109115
this.cacheIsReady.value = true;
110116
this.onGraphCacheChanged();
111117
};
@@ -125,6 +131,16 @@ export default class Graph3dPlugin extends Plugin {
125131
this.app.metadataCache.resolvedLinks
126132
);
127133
this.globalGraph = Graph.createFromApp(this.app);
134+
} else {
135+
console.log(
136+
"changed but ",
137+
this.cacheIsReady.value,
138+
" and ",
139+
shallowCompare(
140+
this._resolvedCache,
141+
this.app.metadataCache.resolvedLinks
142+
)
143+
);
128144
}
129145
};
130146

@@ -165,8 +181,6 @@ export default class Graph3dPlugin extends Plugin {
165181
private async loadSettings(): Promise<GraphSettings> {
166182
const loadedData = await this.loadData(),
167183
settings = GraphSettings.fromStore(loadedData);
168-
console.log("Loaded settings", settings);
169-
console.log("From data", loadedData);
170184
return settings;
171185
}
172186

src/views/atomics/TreeItem.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ export class TreeItem extends HTMLDivElement {
4747
};
4848
}
4949

50-
try {
51-
if (customElements.get("tree-item") === undefined) {
52-
customElements.define("tree-item", TreeItem, { extends: "div" });
53-
}
54-
} catch (e) {
55-
// console.error(e);
50+
if (typeof customElements.get("tree-item") === "undefined") {
51+
customElements.define("tree-item", TreeItem, { extends: "div" });
5652
}

src/views/graph/Graph3dView.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class Graph3dView extends ItemView {
3232
if (viewContent) {
3333
viewContent.classList.add("graph-3d-view");
3434
this.appendGraph(viewContent);
35-
3635
const settings = new GraphSettingsView(
3736
this.plugin.settingsState,
3837
this.plugin.theme

src/views/settings/GraphSettingsView.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,8 @@ export class GraphSettingsView extends HTMLDivElement {
134134
}
135135
}
136136

137-
try {
138-
if (customElements.get("graph-settings-view") == null) {
139-
customElements.define("graph-settings-view", GraphSettingsView, {
140-
extends: "div",
141-
});
142-
}
143-
} catch (e) {
144-
// console.error(e);
137+
if (typeof customElements.get("graph-settings-view") === "undefined") {
138+
customElements.define("graph-settings-view", GraphSettingsView, {
139+
extends: "div",
140+
});
145141
}

0 commit comments

Comments
 (0)