mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
fix(web): use window.installedPlugins for bulk update button (#250)
The previous fix (#249) wired window.updateAllPlugins to PluginInstallManager.updateAll(), but that method reads from PluginStateManager.installedPlugins which is never populated on page load — only after individual install/update operations. Meanwhile, base.html already defined a working updateAllPlugins using window.installedPlugins (reliably populated by plugins_manager.js). The override from install_manager.js masked this working version. Fix: revert install_manager.js changes and rewrite runUpdateAllPlugins to iterate window.installedPlugins directly, calling the API endpoint without any middleman. Adds per-plugin progress in button text and a summary notification on completion. Co-authored-by: Chuck <chuck@example.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,10 +81,9 @@ const PluginInstallManager = {
|
||||
/**
|
||||
* Update all plugins.
|
||||
*
|
||||
* @param {Function} onProgress - Optional callback(index, total, pluginId) for progress updates
|
||||
* @returns {Promise<Array>} Update results
|
||||
*/
|
||||
async updateAll(onProgress) {
|
||||
async updateAll() {
|
||||
if (!window.PluginStateManager || !window.PluginStateManager.installedPlugins) {
|
||||
throw new Error('Installed plugins not loaded');
|
||||
}
|
||||
@@ -92,22 +91,15 @@ const PluginInstallManager = {
|
||||
const plugins = window.PluginStateManager.installedPlugins;
|
||||
const results = [];
|
||||
|
||||
for (let i = 0; i < plugins.length; i++) {
|
||||
const plugin = plugins[i];
|
||||
if (onProgress) onProgress(i + 1, plugins.length, plugin.id);
|
||||
for (const plugin of plugins) {
|
||||
try {
|
||||
const result = await window.PluginAPI.updatePlugin(plugin.id);
|
||||
const result = await this.update(plugin.id);
|
||||
results.push({ pluginId: plugin.id, success: true, result });
|
||||
} catch (error) {
|
||||
results.push({ pluginId: plugin.id, success: false, error });
|
||||
}
|
||||
}
|
||||
|
||||
// Reload plugin list once at the end
|
||||
if (window.PluginStateManager) {
|
||||
await window.PluginStateManager.loadInstalledPlugins();
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
};
|
||||
@@ -117,6 +109,5 @@ if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = PluginInstallManager;
|
||||
} else {
|
||||
window.PluginInstallManager = PluginInstallManager;
|
||||
window.updateAllPlugins = (onProgress) => PluginInstallManager.updateAll(onProgress);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user