shabegom / obsidian-reference-count

Show Reference Count of Block Refs
65 stars 6 forks source link

Search-ref search views snuck into my sidebar and cannot remove #26

Closed GitMurf closed 3 years ago

GitMurf commented 3 years ago

Now sure how or when they snuck in, but something to keep an eye out. It may have been one of the earlier versions we were testing. But you cannot right click them to remove. So either have to revert back to a different workspace to remove them or programmatically remove them from the console.

image

image

GitMurf commented 3 years ago

I was able to remove them via the console with this:

image

Here is code we could use to add to the onunload function of the plugin to make sure to cleanup any remaining search views/panes:

async onunload() {
    this.app.workspace
        .getLeavesOfType('search-ref')
        .forEach((leaf: WorkspaceLeaf) => leaf.detach());
}

@shabegom thoughts on this? Do you see any issue with adding this into the onunload() function?

GitMurf commented 3 years ago

Ok looks like I figured out why/how they got in the sidebar. It looks like it adds them each time you click a block ref counter button? We should definitely implement the onunload() fix above but also should try and figure out how not to add to the sidebar? Or at least hide from the sidebar?

Also maybe we run the same cleanup on obsidian start. So each time we start we start fresh without any old search views. If you click a block ref counter button and don't close the search view and then close Obsidian, when you open it next time you will have a search view in the sidebar that you can't remove.

https://user-images.githubusercontent.com/64155612/120356847-a18c5900-c2b9-11eb-9d2a-447d48836375.mp4

GitMurf commented 3 years ago

Opened up #29 for the second part of the problem which is not letting the Search view be added to the right sidebar or at least hide it from the user.