From 976d4f39e6452f2c1f26575eb0fdf2fb872504d5 Mon Sep 17 00:00:00 2001 From: Gness Erquint Date: Thu, 27 Mar 2025 17:27:17 +0300 Subject: [PATCH] No updates for disabled extensions, unless you insist. --- public/scripts/extensions.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js index ff70819d5..b03cddb9a 100644 --- a/public/scripts/extensions.js +++ b/public/scripts/extensions.js @@ -793,6 +793,16 @@ async function showExtensionsDetails() { }, }; + /** @type {import('./popup.js').CustomPopupButton} */ + const updateEnabledOnlyButton = { + text: t`Update enabled only`, + action: async () => { + requiresReload = true; + await autoUpdateExtensions(false); + await popup.complete(POPUP_RESULT.AFFIRMATIVE); + }, + }; + /** @type {import('./popup.js').CustomPopupButton} */ const sortOrderButton = { text: sortByName ? t`Sort: Display Name` : t`Sort: Loading Order`, @@ -809,7 +819,7 @@ async function showExtensionsDetails() { okButton: t`Close`, wide: true, large: true, - customButtons: [sortOrderButton, updateAllButton], + customButtons: [sortOrderButton, updateEnabledOnlyButton, updateAllButton], allowVerticalScrolling: true, onClosing: async () => { if (waitingForSave) { @@ -1196,7 +1206,7 @@ async function checkForUpdatesManual(sortFn, abortSignal) { } /** - * Checks if there are updates available for 3rd-party extensions. + * Checks if there are updates available for enabled 3rd-party extensions. * @param {boolean} force Skip nag check * @returns {Promise} */ @@ -1218,6 +1228,11 @@ async function checkForExtensionUpdates(force) { const promises = []; for (const [id, manifest] of Object.entries(manifests)) { + const isDisabled = extension_settings.disabledExtensions.includes(id); + if (isDisabled) { + console.debug(`Skipping extension: ${manifest.display_name} (${id}) for non-admin user`) + continue; + } const isGlobal = getExtensionType(id) === 'global'; if (isGlobal && !isCurrentUserAdmin) { console.debug(`Skipping global extension: ${manifest.display_name} (${id}) for non-admin user`); @@ -1247,8 +1262,8 @@ async function checkForExtensionUpdates(force) { } /** - * Updates all 3rd-party extensions that have auto-update enabled. - * @param {boolean} forceAll Force update all even if not auto-updating + * Updates all enabled 3rd-party extensions that have auto-update enabled. + * @param {boolean} forceAll Include disabled and not auto-updating * @returns {Promise} */ async function autoUpdateExtensions(forceAll) { @@ -1260,6 +1275,11 @@ async function autoUpdateExtensions(forceAll) { const isCurrentUserAdmin = isAdmin(); const promises = []; for (const [id, manifest] of Object.entries(manifests)) { + const isDisabled = extension_settings.disabledExtensions.includes(id); + if (!forceAll && isDisabled) { + console.debug(`Skipping extension: ${manifest.display_name} (${id}) for non-admin user`) + continue; + } const isGlobal = getExtensionType(id) === 'global'; if (isGlobal && !isCurrentUserAdmin) { console.debug(`Skipping global extension: ${manifest.display_name} (${id}) for non-admin user`);