Skip to content

Commit

Permalink
1.0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
turulix committed Jan 30, 2024
1 parent 48b236d commit c7d0bfa
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-folder-index",
"name": "Folder Index",
"version": "1.0.22",
"version": "1.0.23",
"minAppVersion": "1.1.16",
"description": "This Plugin will automatically generate a TOC for the current Folder.",
"author": "turulix",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-sample-plugin",
"version": "1.0.22",
"version": "1.0.23",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
23 changes: 13 additions & 10 deletions src/modules/FolderNoteModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class FolderNoteModule {

const file = this.app.vault.getAbstractFileByPath(path)
if (file instanceof TFile) {
await this.app.workspace.getLeaf().openFile(file)
await this.app.workspace.getLeaf(false).openFile(file)
}
}

Expand Down Expand Up @@ -166,15 +166,21 @@ export class FolderNoteModule {
}

private async onLayoutChange() {
const currentLeaf = this.app.workspace.getMostRecentLeaf()
if (currentLeaf == null) {
return;
}
const currentState = currentLeaf.getViewState();

try {
// try {
if (this.previousState == null) {
this.previousState = this.app.workspace.getLeaf().getViewState()
this.previousState = currentLeaf.getViewState();
}
if (!this.plugin.settings.autoPreviewMode) {
return;
}

const currentState = this.app.workspace.getLeaf().getViewState()

// We weren't in a markdown file before, so we don't care
if (!(currentState.type == "markdown" && this.previousState.type == "markdown")) {
Expand All @@ -184,31 +190,28 @@ export class FolderNoteModule {
// We didn't change files, so we don't care
if (currentState.state.file == this.previousState.state.file)
return;

const currentFile = this.app.vault.getAbstractFileByPath(currentState.state.file) as TFile

// We did not open an index file, so we need to check if the previous mode was set by this plugin
if (!isIndexFile(currentFile.path)) {
if (this.viewModeByPlugin) {
this.viewModeByPlugin = false
currentState.state.mode = "source"
await this.app.workspace.getLeaf().setViewState(currentState)
await currentLeaf.setViewState(currentState)
}
return;
}

// We are already inside the Preview Mode.
// // We are already inside the Preview Mode.
if (this.previousState.state.mode == "preview") {
return;
} else {
currentState.state.mode = "preview"
this.viewModeByPlugin = true
await this.app.workspace.getLeaf().setViewState(currentState)
await currentLeaf.setViewState(currentState)
}
} finally {
const currentState = this.app.workspace.getLeaf().getViewState();
if (currentState.type == "markdown")
this.previousState = currentState;
this.previousState = currentLeaf.getViewState();
}
}

Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"1.0.19": "1.1.16",
"1.0.20": "1.1.16",
"1.0.21": "1.1.16",
"1.0.22": "1.1.16"
"1.0.22": "1.1.16",
"1.0.23": "1.1.16"
}

0 comments on commit c7d0bfa

Please sign in to comment.