nathonius / obsidian-collapse-all

MIT License
92 stars 2 forks source link

Tagpane: Open All Folders / Close All Folders #10

Closed Gregory-Esman closed 2 years ago

Gregory-Esman commented 3 years ago

Hey.

I was recommended to recommend a feature to your plugin.

I have 11,070 arrows point down to subtags in my 2015 year tag.

But 2015 isn't the only year I have. I have every single year from 2015-2021. Each with likely just as many arrows I'd have to click to close everything.

Collapsing them all would take... Time. image

(A subfolder for every month. Within every month there is every day, hour, minute, second, and timezone)

Would you be able to add the feature to collapse all tags in addition to collapsing all folders?

Thanks a lot!

nathonius commented 3 years ago

I'll take a look. If it's easy to adapt, I can add this.

nathonius commented 3 years ago

@Gregory-Esman I've taken a look at it and it's definitely feasible. I may ask you to do a bit of testing for me since you have the perfect setup with tons and tons of nested tags. Basically a worst case scenario since while the file explorer is flat (it's visually nested, but stored as a flat list), the tag pane is stored in a nested list.

If I sent you a main.js and manifest.json file in a gist, would you be amenable to replacing the contents of this plugin in your vault to test performance?

Gregory-Esman commented 3 years ago

Happy to help! Would I be adding these files to the tagpane plugin, or yours, to then have this extra functionality and be able to test it for you?

nathonius commented 3 years ago

@Gregory-Esman In your vault folder replace the main.js file in .obsidian/plugins/obsidian-collapse-all-plugin with the one from this gist:

https://gist.github.com/OfficerHalf/d481232ce04b73099803562846f9792b

If you'd like to backup the original file, you can, but uninstalling and re-installing the plugin would also revert it. You'll need to either restart obsidian or Ctrl+P -> Reload app without saving. After that it should work for tags.

The main thing I'm interested in is performance. If you use the app normally does it seem slower? Does collapsing/expanding the tag pane seem instant? Slow? Any obvious issues otherwise? Let me know what you find!

If it works well for you, feel free to keep that file there until I release the real thing. Once I do, it will automatically be updated to the release version.

Gregory-Esman commented 3 years ago

Got it, will do! I will finish up a few outstanding projects I have to do, place them all on external hard drives, and test this thoroughly. Reason being is I loaded the new main.js file in, opened Obsidian, and my mac DIED. I need to do more testing to figure out if this is caused by your plugin - I'm not saying that it was. For now, i'll call it a simple coincidence. Nonetheless, I want to be prudent and ensure my outstanding projects are delivered before I risk breaking my computer (Which I'm fine doing - Everything is on removable drives). Checking out the console, I believe the total number of hashtags I have is a little more than 1.3M, can you believe it?

I'll update you soon, with a focus on the interests you stated above. Thank you for the quick turnaround!

nathonius commented 3 years ago

Wow, I'm sorry to hear that. I certainly don't think it could have been me causing that 😰 in the very worst case it might have caused obsidian to crash, but even that seems pretty unlikely.

Gregory-Esman commented 3 years ago

Oh no worries at all! I will explore soon :)

nathonius commented 3 years ago

I've tinkered and tinkered and this just doesn't seem possible in your case with the way the tag pane is built now. There are two issues:

  1. the tags themselves are stored in a hierarchy rather than a flat list
  2. the pane isn't smart enough not to re-render on every change to any tag's collapse state, even if that tag isn't visible. This is why though it seems to be finished collapsing everything, obsidian slows to a crawl. I think.

I may revisit this later but for now I'm going to have to put it on hold. Thank you for the deep dive testing you did.

Gregory-Esman commented 3 years ago

Hey,

Thanks for taking a look at it! Curiously, is there a way to force the tagpane plugin to restart? This could be a temporary work around. After everything collapses, force restart. It will bypass Obsidian slowing to a crawl.

On Wed, Sep 22, 2021 at 10:39 AM Nathan @.***> wrote:

I've tinkered and tinkered and this just doesn't seem possible in your case with the way the tag pane is built now. There are two issues:

  1. the tags themselves are stored in a hierarchy rather than a flat list
  2. the pane isn't smart enough not to re-render on every change to any tag's collapse state, even if that tag isn't visible. This is why though it seems to be finished collapsing everything, obsidian slows to a crawl. I think.

I may revisit this later but for now I'm going to have to put it on hold. Thank you for the deep dive testing you did.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficerHalf/obsidian-collapse-all/issues/10#issuecomment-925141411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU36DD4Z6WT5EQL3BSLZFETUDIIGTANCNFSM5BKFWGHQ .

-- Greg Esman

nathonius commented 3 years ago

@Gregory-Esman

Okay, actually one more attempt. It's the same gist and instructions, but the file is different: https://gist.github.com/OfficerHalf/d481232ce04b73099803562846f9792b

This time each call to collapse a single level of tags is wrapped in requestAnimationFrame, which should help make it non-blocking. If this is better but still not working correctly, I can try once more with every single collapse call wrapped in requestAnimationFrame.

nathonius commented 2 years ago

This was added in #17 but you'll likely face the same issues we saw with performance. Will track that in #18