From 5192e9b74ed1a34d041fa5c53519e653b3596587 Mon Sep 17 00:00:00 2001 From: Grace Kind Date: Wed, 13 May 2026 13:46:28 -0500 Subject: [PATCH] Share plugin info across views --- package.json | 2 +- src/js/plugins/pluginService.js | 9 +++++++-- src/js/views/settings/plugins.view.js | 15 ++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index cbf76008..464e13fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.14.9", + "version": "0.14.10", "type": "module", "scripts": { "start": "rm -rf build && NODE_ENV=development eleventy --serve", diff --git a/src/js/plugins/pluginService.js b/src/js/plugins/pluginService.js index e3f26558..2667410f 100644 --- a/src/js/plugins/pluginService.js +++ b/src/js/plugins/pluginService.js @@ -22,6 +22,7 @@ export class PluginService extends EventEmitter { feedFilters: new Set(), settingTabs: new Map(), }; + this._pluginsInfo = null; this.localOnly = localOnly; this.registry = new PluginRegistry(PLUGIN_REGISTRY_URL, { localOnly }); this.pluginCache = new PluginCache(); @@ -175,7 +176,11 @@ export class PluginService extends EventEmitter { return this.registries.settingTabs.get(pluginId) ?? null; } - async listInstalledPlugins() { + getPluginsInfo() { + return this._pluginsInfo; + } + + async loadPluginsInfo() { const installed = this._getInstalled(); const results = await Promise.all( installed.map(async (entry) => { @@ -193,7 +198,7 @@ export class PluginService extends EventEmitter { }; }), ); - return results.filter((entry) => entry !== null); + this._pluginsInfo = results.filter((entry) => entry !== null); } async loadEnabledPlugins() { diff --git a/src/js/views/settings/plugins.view.js b/src/js/views/settings/plugins.view.js index e8675ed6..db43ec7f 100644 --- a/src/js/views/settings/plugins.view.js +++ b/src/js/views/settings/plugins.view.js @@ -25,16 +25,11 @@ class SettingsPluginsView extends View { await requireAuth(); const state = { - plugins: [], - loading: true, uninstallingIds: new Set(), }; async function loadPlugins() { - state.loading = true; - renderPage(); - state.plugins = await pluginService.listInstalledPlugins(); - state.loading = false; + await pluginService.loadPluginsInfo(); renderPage(); } @@ -75,6 +70,7 @@ class SettingsPluginsView extends View { notificationService?.getNumNotifications() ?? null; const numChatNotifications = chatNotificationService?.getNumNotifications() ?? null; + const pluginsInfo = pluginService.getPluginsInfo(); render( html`
${mainLayoutTemplate({ @@ -110,9 +106,9 @@ class SettingsPluginsView extends View { >${chevronRightIconTemplate()} - ${state.loading + ${!pluginsInfo ? html`

Loading…

` - : state.plugins.length === 0 + : pluginsInfo.length === 0 ? html`
No plugins installed @@ -123,7 +119,7 @@ class SettingsPluginsView extends View {

` : html`
    - ${state.plugins.map( + ${pluginsInfo.map( (plugin) => html`
  • { window.scrollTo(0, 0); + renderPage(); loadPlugins(); }); -- 2.51.2