Skip to content

Commit

Permalink
Fixed:
Browse files Browse the repository at this point in the history
- Now tree updating has been got back to valid without losing efficiency.

New feature:
- We can open the separated file list in a current pane or a new separated pane.
  • Loading branch information
vrtmrz committed Nov 17, 2023
1 parent 3abebb1 commit a4c39f0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
3 changes: 3 additions & 0 deletions TagFolderViewComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
}
$: isMainTree = tags.length == 0;
let scrollParent: HTMLDivElement;
const componentHash = `${Math.random()}`;
setContext("viewID", componentHash);
</script>

<div hidden bind:this={iconDivEl} />
Expand Down
5 changes: 3 additions & 2 deletions V2TreeFolderComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import { collectTreeChildren, performSortExactFirst } from "./v2codebehind";
import TreeItemItemComponent from "V2TreeItemComponent.svelte";
import OnDemandRender from "OnDemandRender.svelte";
import { tick } from "svelte";
import { getContext, tick } from "svelte";
// -- Props --
Expand Down Expand Up @@ -516,8 +516,9 @@
isUpdating = false;
});
}
const viewContextID = `${getContext("viewID") ?? ""}`;
$: {
const key = trailKey + (isRoot ? "-r" : "-x");
const key = trailKey + (isRoot ? "-r" : "-x") + viewContextID;
const param = {
key,
expandLimit,
Expand Down
35 changes: 29 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
VIEW_TYPE_TAGFOLDER_LIST,
type ViewItem,
VIEW_TYPE_TAGFOLDER_LINK,
type FileCache
type FileCache,
enumShowListIn
} from "types";
import { allViewItems, allViewItemsByLink, appliedFiles, currentFile, maxDepth, searchString, selectedTags, tagFolderSetting, tagInfo } from "store";
import {
Expand Down Expand Up @@ -1109,10 +1110,21 @@ export default class TagFolderPlugin extends Plugin {
// Cancel if the tagfolder has been disappeared.
return;
}
if (!Platform.isMobile) {
theLeaf = this.app.workspace.createLeafBySplit(parent, "horizontal", false);
} else {
theLeaf = this.app.workspace.getLeftLeaf(false);
switch (this.settings.showListIn) {
case "CURRENT_PANE":
theLeaf = this.app.workspace.getLeaf();
break;
case "SPLIT_PANE":
theLeaf = this.app.workspace.getLeaf("split", "horizontal");
break;
case "":
default:
if (!Platform.isMobile) {
theLeaf = this.app.workspace.createLeafBySplit(parent, "horizontal", false);
} else {
theLeaf = this.app.workspace.getLeftLeaf(false);
}
break;
}
}
const title = tags.map((e) =>
Expand All @@ -1126,7 +1138,6 @@ export default class TagFolderPlugin extends Plugin {
active: true,
state: { tags: tags, title: title } as TagFolderListState
});
// (theLeaf.view as TagFolderList).setTreeRoot(this.root);

this.app.workspace.revealLeaf(
theLeaf
Expand Down Expand Up @@ -1386,6 +1397,18 @@ class TagFolderSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
});
});
new Setting(containerEl)
.setName("Show list in")
.setDesc("This option applies to the newly opened list")
.addDropdown((dropdown) => {
dropdown
.addOptions(enumShowListIn)
.setValue(this.plugin.settings.showListIn)
.onChange(async (value) => {
this.plugin.settings.showListIn = value as keyof typeof enumShowListIn;
await this.plugin.saveSettings();
});
});
containerEl.createEl("h3", { text: "Arrangements" });

new Setting(containerEl)
Expand Down
8 changes: 7 additions & 1 deletion types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export type LinkParseConf = {
key: string
}
}
export const enumShowListIn = {
"": "Sidebar",
"CURRENT_PANE": "Current pane",
"SPLIT_PANE": "New pane",
}

export interface TagFolderSettings {
displayMethod: DISPLAY_METHOD;
Expand Down Expand Up @@ -80,7 +85,7 @@ export interface TagFolderSettings {
linkConfig: LinkParseConf;
linkShowOnlyFDR: boolean;
linkCombineOtherTree: boolean;

showListIn: keyof typeof enumShowListIn;
}

export const DEFAULT_SETTINGS: TagFolderSettings = {
Expand Down Expand Up @@ -125,6 +130,7 @@ export const DEFAULT_SETTINGS: TagFolderSettings = {
},
linkShowOnlyFDR: true,
linkCombineOtherTree: true,
showListIn: ""
};

export const VIEW_TYPE_SCROLL = "tagfolder-view-scroll";
Expand Down

0 comments on commit a4c39f0

Please sign in to comment.