-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orphaned ItemView tab on reload #22
Comments
If you have a link to the source I can take a look, but I don't know of anything that would do this off the top of my head. Are you using the |
Well... after over 1 year of plugin development, I never knew that API method exists! I'll try that first and see if it helps. Thanks for the speedy reply. My code can be found here: JWL Linker, it's all JS not TS. There are 3 other sidebar view based plugins in the repository, there all have the same problem. |
Hm. You have some code to remove the old leaf, but that shouldn't be necessary; recent versions of Obsidian put up a temporary view proxy that it'll refresh with the real view once 1) the plugin is loaded, and 2) the leaf is revealed. However, it's possible that there's been a change in how that gets done, in such a way that Hot Reload isn't triggering the mechanism any more. (Though that seems unlikely.) What version of Obsidian are you on, precisely? The only other thing I can think of is that using an async onload method can result in some weirdness if you save a change at the same time a previous hot reload is occurring, but it's unlikely you'd trigger such a thing consistently, I don't think. |
I agree it should not be necessary, but right now this is just a workaround! I was also wondering if it has anything to do with the new 'Deferred Views' feature. I am on the latest version (1.7.7 update and installer). It is consistent. If I manually disable / enable the plugin after a code change it refreshes fine. If I use hot-reload I always get a 2nd orphaned View tab ('Plugin is no longer active'). |
I made the following changes and now it works correctly... Not really sure I can explain why 🤔 async reload(plugin) {
const plugins = this.app.plugins; // <-- added this. as using app is deprecated.
// Don't reload disabled plugins
if (!plugins.enabledPlugins.has(plugin)) return;
await plugins.disablePluginAndSave(plugin); // <-- changed to the ...AndSave() version
console.debug("disabled", plugin); There are a few more unqualified |
I am developing a plugin that creates an ItemView in the sidebar. When I use hot-reload to disable/enable my plugin it always leaves an orphaned ItemView tab behind and creates a 2nd new one instead. If I manually disable and re-enable the plugin in the settings this does not happen.
Any ideas what could be causing this and how I might trouble-shoot this?
The text was updated successfully, but these errors were encountered: