Skip to content

Commit

Permalink
prevent opening multiple views
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpetro committed Jan 1, 2023
1 parent 7de5442 commit 8edd883
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,19 @@ class SmartConnectionsPlugin extends Obsidian.Plugin {
console.log("view already open");
return;
}
for (let leaf of this.app.workspace.getLeavesOfType(SMART_CONNECTIONS_VIEW_TYPE)) {
if (leaf.view instanceof SmartConnectionsView) {
this.view = leaf.view;
console.log("found view, setting to this.view")
return;
}
}
console.log("view not found, creating new view");
const right_leaf = this.app.workspace.getRightLeaf(false);
await right_leaf.setViewState({
type: SMART_CONNECTIONS_VIEW_TYPE,
active: true,
});

});
for (let leaf of this.app.workspace.getLeavesOfType(SMART_CONNECTIONS_VIEW_TYPE)) {
this.app.workspace.revealLeaf(leaf);
if (leaf.view instanceof SmartConnectionsView) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Smart Connections",
"author": "Brian Petro",
"description": "Find links to similar notes using artificial intelligence from OpenAI.",
"version": "1.0.12",
"version": "1.0.13",
"minAppVersion": "1.1.0",
"authorUrl": "https://wfhbrian.com",
"isDesktopOnly": true
Expand Down

0 comments on commit 8edd883

Please sign in to comment.