mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
PluginService: proper restore of a barwidget after updating a plugin.
This commit is contained in:
@@ -344,7 +344,7 @@ Singleton {
|
||||
}
|
||||
|
||||
// Enable a plugin
|
||||
function enablePlugin(pluginId) {
|
||||
function enablePlugin(pluginId, skipAddToBar) {
|
||||
if (PluginRegistry.isPluginEnabled(pluginId)) {
|
||||
Logger.w("PluginService", "Plugin already enabled:", pluginId);
|
||||
return true;
|
||||
@@ -358,11 +358,13 @@ Singleton {
|
||||
PluginRegistry.setPluginEnabled(pluginId, true);
|
||||
loadPlugin(pluginId);
|
||||
|
||||
// Add plugin widget to bar if it provides one
|
||||
var manifest = PluginRegistry.getPluginManifest(pluginId);
|
||||
if (manifest && manifest.entryPoints && manifest.entryPoints.barWidget) {
|
||||
var widgetId = "plugin:" + pluginId;
|
||||
addWidgetToBar(widgetId, "right"); // Default to right section
|
||||
// Add plugin widget to bar if it provides one (unless we're restoring from backup)
|
||||
if (!skipAddToBar) {
|
||||
var manifest = PluginRegistry.getPluginManifest(pluginId);
|
||||
if (manifest && manifest.entryPoints && manifest.entryPoints.barWidget) {
|
||||
var widgetId = "plugin:" + pluginId;
|
||||
addWidgetToBar(widgetId, "right"); // Default to right section
|
||||
}
|
||||
}
|
||||
|
||||
updatePluginInAvailable(pluginId, {
|
||||
@@ -994,15 +996,16 @@ Singleton {
|
||||
if (success) {
|
||||
Logger.i("PluginService", "Plugin updated successfully:", pluginId);
|
||||
|
||||
// Restore bar layout
|
||||
// Re-enable the plugin first, so the new component is registered
|
||||
// Skip adding to bar since we'll restore the layout from backup
|
||||
enablePlugin(pluginId, true);
|
||||
|
||||
// Then restore bar layout (so BarWidgetLoaders can find the new component)
|
||||
Settings.data.bar.widgets.left = barBackup.left;
|
||||
Settings.data.bar.widgets.center = barBackup.center;
|
||||
Settings.data.bar.widgets.right = barBackup.right;
|
||||
Logger.d("PluginService", "Restored bar layout");
|
||||
|
||||
// Re-enable the plugin
|
||||
enablePlugin(pluginId);
|
||||
|
||||
// Remove from updates list
|
||||
var updates = Object.assign({}, root.pluginUpdates);
|
||||
delete updates[pluginId];
|
||||
|
||||
Reference in New Issue
Block a user