Update to ensure view is open before sending notices

:q
This commit is contained in:
Mossy426 2024-08-09 11:23:34 -04:00
parent 0f0b2d5724
commit 8b946408e5
4 changed files with 30 additions and 8 deletions

View file

@ -1,5 +1,6 @@
import { Plugin, ItemView, WorkspaceLeaf, debounce, Notice } from 'obsidian';
import * as d3 from "d3";
import _ from 'lodash';
const DEFAULT_NETWORK_SETTINGS : any = {
relevanceScoreThreshold: 0.5,
@ -1322,7 +1323,7 @@ class ScGraphItemView extends ItemView {
watchForNoteChanges() {
this.app.workspace.on('file-open', (file) => {
if (file && (this.currentNoteKey !== file.path) && !this.isHovering) {
if (file && (this.currentNoteKey !== file.path) && !this.isHovering && this.containerEl.children[1].checkVisibility()) {
this.currentNoteKey = file.path;
this.currentNoteChanging = true;
this.render();
@ -1458,6 +1459,10 @@ class ScGraphItemView extends ItemView {
this.maxScore = 0;
if (!this.currentNoteKey) return;
this.centralNote = this.smartNotes[this.currentNoteKey];
console.log('central note: ', this.centralNote);
// console.log('central note connections: ', parse(stringify(this.centralNote.find_connections())));
const noteConnections = this.centralNote.find_connections().filter(
(connection: any) => connection.score >= this.relevanceScoreThreshold);
this.addCentralNode();

24
package-lock.json generated
View file

@ -1,19 +1,22 @@
{
"name": "smart-connections-visualizer",
"version": "1.0.2",
"version": "1.0.12",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "smart-connections-visualizer",
"version": "1.0.2",
"version": "1.0.12",
"license": "MIT",
"dependencies": {
"bootstrap": "^5.3.3",
"d3": "^7.9.0"
"d3": "^7.9.0",
"flatted": "^3.3.1",
"lodash": "^4.17.21"
},
"devDependencies": {
"@types/d3": "^7.4.3",
"@types/lodash": "^4.17.7",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
@ -817,6 +820,12 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"dev": true
},
"node_modules/@types/lodash": {
"version": "4.17.7",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz",
"integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==",
"dev": true
},
"node_modules/@types/node": {
"version": "16.18.97",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.97.tgz",
@ -2065,9 +2074,7 @@
"node_modules/flatted": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz",
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
"dev": true,
"peer": true
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw=="
},
"node_modules/fs.realpath": {
"version": "1.0.0",
@ -2363,6 +2370,11 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",

View file

@ -20,6 +20,7 @@
"license": "MIT",
"devDependencies": {
"@types/d3": "^7.4.3",
"@types/lodash": "^4.17.7",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
@ -32,6 +33,8 @@
},
"dependencies": {
"bootstrap": "^5.3.3",
"d3": "^7.9.0"
"d3": "^7.9.0",
"flatted": "^3.3.1",
"lodash": "^4.17.21"
}
}

View file

@ -10,6 +10,8 @@
"moduleResolution": "node",
"importHelpers": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true, // This is often recommended alongside
"strictNullChecks": true,
"lib": [
"DOM",