mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-23 15:36:52 +00:00
Fixed: Shadow tiddlers don't refresh when their plugin is deleted/modified
This commit is contained in:
parent
50a3c5526f
commit
7327a3fb92
@ -24,6 +24,7 @@ var PREFIX_CONFIG_REGISTER_PLUGIN_TYPE = "$:/config/RegisterPluginType/";
|
|||||||
exports.startup = function() {
|
exports.startup = function() {
|
||||||
$tw.wiki.addTiddler({title: TITLE_REQUIRE_RELOAD_DUE_TO_PLUGIN_CHANGE,text: "no"});
|
$tw.wiki.addTiddler({title: TITLE_REQUIRE_RELOAD_DUE_TO_PLUGIN_CHANGE,text: "no"});
|
||||||
$tw.wiki.addEventListener("change",function(changes) {
|
$tw.wiki.addEventListener("change",function(changes) {
|
||||||
|
// Work out which of the changed tiddlers are plugins that we need to reregister
|
||||||
var changesToProcess = [],
|
var changesToProcess = [],
|
||||||
requireReloadDueToPluginChange = false;
|
requireReloadDueToPluginChange = false;
|
||||||
$tw.utils.each(Object.keys(changes),function(title) {
|
$tw.utils.each(Object.keys(changes),function(title) {
|
||||||
@ -38,6 +39,7 @@ exports.startup = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Issue warning if any of the tiddlers require a reload
|
||||||
if(requireReloadDueToPluginChange) {
|
if(requireReloadDueToPluginChange) {
|
||||||
$tw.wiki.addTiddler({title: TITLE_REQUIRE_RELOAD_DUE_TO_PLUGIN_CHANGE,text: "yes"});
|
$tw.wiki.addTiddler({title: TITLE_REQUIRE_RELOAD_DUE_TO_PLUGIN_CHANGE,text: "yes"});
|
||||||
}
|
}
|
||||||
@ -45,12 +47,35 @@ exports.startup = function() {
|
|||||||
if(changesToProcess.length > 0) {
|
if(changesToProcess.length > 0) {
|
||||||
var changes = $tw.wiki.readPluginInfo(changesToProcess);
|
var changes = $tw.wiki.readPluginInfo(changesToProcess);
|
||||||
if(changes.modifiedPlugins.length > 0 || changes.deletedPlugins.length > 0) {
|
if(changes.modifiedPlugins.length > 0 || changes.deletedPlugins.length > 0) {
|
||||||
|
var changedShadowTiddlers = {};
|
||||||
|
// Collect the shadow tiddlers of any deleted plugins
|
||||||
|
$tw.utils.each(changes.deletedPlugins,function(pluginTitle) {
|
||||||
|
var pluginInfo = $tw.wiki.getPluginInfo(pluginTitle);
|
||||||
|
if(pluginInfo) {
|
||||||
|
$tw.utils.each(Object.keys(pluginInfo.tiddlers),function(title) {
|
||||||
|
changedShadowTiddlers[title] = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Collect the shadow tiddlers of any modified plugins
|
||||||
|
$tw.utils.each(changes.modifiedPlugins,function(pluginTitle) {
|
||||||
|
var pluginInfo = $tw.wiki.getPluginInfo(pluginTitle);
|
||||||
|
if(pluginInfo) {
|
||||||
|
$tw.utils.each(Object.keys(pluginInfo.tiddlers),function(title) {
|
||||||
|
changedShadowTiddlers[title] = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
// (Re-)register any modified plugins
|
// (Re-)register any modified plugins
|
||||||
$tw.wiki.registerPluginTiddlers(null,changes.modifiedPlugins);
|
$tw.wiki.registerPluginTiddlers(null,changes.modifiedPlugins);
|
||||||
// Unregister any deleted plugins
|
// Unregister any deleted plugins
|
||||||
$tw.wiki.unregisterPluginTiddlers(null,changes.deletedPlugins);
|
$tw.wiki.unregisterPluginTiddlers(null,changes.deletedPlugins);
|
||||||
// Unpack the shadow tiddlers
|
// Unpack the shadow tiddlers
|
||||||
$tw.wiki.unpackPluginTiddlers();
|
$tw.wiki.unpackPluginTiddlers();
|
||||||
|
// Queue change events for the changed shadow tiddlers
|
||||||
|
$tw.utils.each(Object.keys(changedShadowTiddlers),function(title) {
|
||||||
|
$tw.wiki.enqueueTiddlerEvent(title,changedShadowTiddlers[title]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user