Skip to content

Commit

Permalink
Merge pull request #13 from DylanHojnoski/startup-delete-bug
Browse files Browse the repository at this point in the history
Startup delete bug
  • Loading branch information
DylanHojnoski authored Mar 9, 2024
2 parents 68178b3 + 9e214f5 commit a4dc9d9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ export default class ObsidianGraphs extends Plugin {
currentFileName: string;
count = 0;


async onload () {

setMathFunctions();

this.app.workspace.on("file-open" , () => {

// set the current file
const currentFile = this.app.workspace.getActiveFile();
if (currentFile) {
this.currentFileName = currentFile.name.substring(0, currentFile.name.indexOf("."))
this.currentFileName = this.currentFileName.replace(/\s/g, "");
}
setCurrentFileName();

// get the active files
const activeFileNames: string[] = [];
Expand Down Expand Up @@ -65,6 +61,11 @@ export default class ObsidianGraphs extends Plugin {

let board: Board;

// if the current file name is undefined need to get the current file
if (this.currentFileName == undefined) {
setCurrentFileName();
}

// create the div that contains the board
const graphDiv = element.createEl("div", {cls: "jxgbox " + this.currentFileName});
graphDiv.id = "graph" + this.count;
Expand Down Expand Up @@ -110,3 +111,11 @@ export default class ObsidianGraphs extends Plugin {
}

}

function setCurrentFileName() {
const currentFile = this.app.workspace.getActiveFile();
if (currentFile) {
this.currentFileName = currentFile.name.substring(0, currentFile.name.indexOf("."))
this.currentFileName = this.currentFileName.replace(/\s/g, "");
}
}

0 comments on commit a4dc9d9

Please sign in to comment.