Closed raisabelatrix closed 1 year ago
Same issue, but using Obsidian ver. 0.16.2
Same issue too on Linux with Obsidian 0.15.9
Same issue on Windows 10, Obsidian 1.0.0
Same issue with macOS 12.6, File Hider 1.1.0, Obsidian 1.0.0 (also had this issue in previous Obsidian versions)
same issue, i believe it started doing this for me after i enabled File & Links > Detect All Extensions. i could be wrong about that.
Same here. macOS + Version 1.1.9 (Installer 1.1.8)
Same issue, under Ubuntu 22.04.1LTS, Obsidian 1.1.9, File Hider 1.1.0 Bug can be 'corrected' if File & Links > Detect All Extensions is disable. @KennethRamsey @raisabelatrix
sorry @leroycharles but that does not fix the issue for me. I'm on windows 10.
I think I've found the issue. When the plugin loads and changePathVisibility
is called for every hidden path, the Files plugin sidebar dom nodes aren't loaded yet.
This was probably introduced in the latest version, as the plugin now uses inline styles rather than a stylesheet, where this would be no problem at all.
A temporary fix is to sleep a few milliseconds before invoking this.app.workspace.onLayoutReady
, allowing the Files core plugin to load.
So, for everyone who just wants the plugin to work: open .obsidian/plugins/OA-file-hider/main.js
in your vault and add the following line before the this.app.workspace.onLayoutReady
call (l. 191):
yield sleep(1000);
and reopen your vault.
If that doesn't work, try increasing the number of milliseconds; it just increases the delay when the files are hidden on vault open.
So, for everyone who just wants the plugin to work: open
.obsidian/plugins/OA-file-hider/main.js
in your vault and add the following line before thethis.app.workspace.onLayoutReady
call (l. 191):yield sleep(1000);
and reopen your vault.
I tried out this solution.
With a sleep of 1500 the hidden files do stay hidden after a restart, so your conclusion is right. Unfortunately this introduces another, possibly worse, bug: in any other subsequent launch of Obsidian every file and folder under Files is completely gone (not deleted, just not showing up) and will only reappear after deleting the new yield sleep(1500);
line and rolling back to the original main.js
.
Tested on Obsidian 1.1.9 on Windows 10
I tried out this solution. With a sleep of 1500 the hidden files do stay hidden after a restart, so your conclusion is right. Unfortunately this introduces another, possibly worse, bug: in any other subsequent launch of Obsidian every file and folder under Files is completely gone (not deleted, just not showing up) and will only reappear after deleting the new
yield sleep(1500);
line and rolling back to the originalmain.js
.Tested on Obsidian 1.1.9 on Windows 10
When you look at the source code, what you're describing makes absolutely no sense; all it does is defer the plugin load.
For me it works perfectly, on Obsidian 1.1.9 on macOS 13.1.
You could try to reproduce this on a clean vault; perhaps another plugin or theme is interfering here.
This works for me too, on Obsidian 1.1.9 and Linux, opensuse 15.4
I did encounter a small side issue: I was trying out theMAKE.md plugin, and while this solution worked to hide folders in the make.md file list it did not hide them in the core file explorer. When I disable the make.md plugin this works as expected.
@Oliver-Akins If I revert to 9d24a134e1fa6a9cf7dd8da68328eb5b432438bc (prior to the implementation of inline-styles), the following issues appear to be resolved:
Would you accept a PR in which we return to a stylesheet-based solution, because I believe that using a MutationObserver here to keep the inline-styles would not only make it more complex, but I'm also not sure if it would solve #23.
I did encounter a small side issue: I was trying out theMAKE.md plugin, and while this solution worked to hide folders in the make.md file list it did not hide them in the core file explorer. When I disable the make.md plugin this works as expected.
Try changing
let n = document.querySelector(`[data-path="${path}"]`);
(l. 130)
to
let n = document.querySelector(`.nav-folder-children [data-path="${path}"]`);
This should limit this plugin to the core file explorer.
@jess1k Yeah, I'm open to PRs if anyone wants to submit them and then I can publish release(s) as needed
I did encounter a small side issue: I was trying out theMAKE.md plugin, and while this solution worked to hide folders in the make.md file list it did not hide them in the core file explorer. When I disable the make.md plugin this works as expected.
Try changing
let n = document.querySelector(`[data-path="${path}"]`);
(l. 130) tolet n = document.querySelector(`.nav-folder-children [data-path="${path}"]`);
This should limit this plugin to the core file explorer.
Thank you very much for this! This works to hide the file in the file explorer.
I have now noticed that files do not stay hidden. After some time files and folders that are hidden at startup have reappeared. I haven't yet managed to pin down if it something I am doing or if it just happens after some amount of time has passed.
Can confirm this is an issue on all my systems: two different macOS Monterey (one Intel, one M1) and Windows 10, using the same vault. Files are unhidden upon restart. Triggering the command twice hides them.
I currently only use this for hiding _resource-folders.
Replacing the whole onLayoutReady
block on line 191 with this works much more consistently and is basically instantaneous. No need to worry about waiting for 1 or 2 seconds for things to hide or load.
this.app.workspace.onLayoutReady(() => {
setTimeout(() => {
for (const path of this.settings.hiddenList) {
changePathVisibility(path, this.settings.hidden);
}
}, 0);
});
Thanks, this works much faster, but it only hides things that would be visible when Obsidian loads. For instance I use the plugin to hide some sub-folders of a folder. If the folder would be expanded when Obsidian opens the sub-folders are hidden. But if the folder is collapsed when Obsidian opens and I expand it after the sub-folders that should be hidden are visible.
This has been implemented by @KosmosisDire and a new release has been published (1.1.1
)
I think this bug is still present because I am still experiencing it.
There is still a bug affecting folders that are nested in root folders. Folders on the first level work fine.
Plugin Version
1.1.0
Obsidian Version
0.15.9
Affected Platforms
Windows
Expected Behaviour
Actual Behaviour
Steps to Reproduce