diff options
| author | marios <marios8543@gmail.com> | 2025-10-07 02:40:41 +0300 |
|---|---|---|
| committer | marios <marios8543@gmail.com> | 2025-10-07 02:40:41 +0300 |
| commit | 968c8b113c4ec52d121520aac7879a31c2856446 (patch) | |
| tree | 72a33f71d7682965a4ee1320442e3ac2043135e1 | |
| parent | 6fac72112c28bc57512f6522304bc29df7431f9e (diff) | |
| download | decky-loader-marios8543/plugin-disable.tar.gz decky-loader-marios8543/plugin-disable.zip | |
working plugin disable, not tested extensivelymarios8543/plugin-disable
| -rw-r--r-- | backend/decky_loader/utilities.py | 4 | ||||
| -rw-r--r-- | frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx | 19 | ||||
| -rw-r--r-- | frontend/src/components/settings/pages/plugin_list/index.tsx | 13 | ||||
| -rw-r--r-- | frontend/src/plugin-loader.tsx | 23 |
4 files changed, 47 insertions, 12 deletions
diff --git a/backend/decky_loader/utilities.py b/backend/decky_loader/utilities.py index 63ffff06..ea797dad 100644 --- a/backend/decky_loader/utilities.py +++ b/backend/decky_loader/utilities.py @@ -80,6 +80,8 @@ class Utilities: context.ws.add_route("utilities/restart_webhelper", self.restart_webhelper) context.ws.add_route("utilities/close_cef_socket", self.close_cef_socket) context.ws.add_route("utilities/_call_legacy_utility", self._call_legacy_utility) + context.ws.add_route("utilities/enable_plugin", self.enable_plugin) + context.ws.add_route("utilities/disable_plugin", self.disable_plugin) context.web_app.add_routes([ post("/methods/{method_name}", self._handle_legacy_server_method_call) @@ -481,7 +483,7 @@ class Utilities: await self.set_setting("disabled_plugins", disabled_plugins) await self.context.plugin_loader.plugins[name].stop() - await self.context.ws.emit("loader/unload_plugin", name) + await self.context.ws.emit("loader/disable_plugin", name) async def enable_plugin(self, name: str): disabled_plugins: List[str] = await self.get_setting("disabled_plugins", []) diff --git a/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx b/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx index fec03e56..416d693e 100644 --- a/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx +++ b/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx @@ -1,15 +1,16 @@ import { FC } from 'react'; import { useTranslation } from 'react-i18next'; -import { FaEyeSlash, FaLock } from 'react-icons/fa'; +import { FaEyeSlash, FaLock, FaMoon } from 'react-icons/fa'; interface PluginListLabelProps { frozen: boolean; hidden: boolean; + disabled: boolean; name: string; version?: string; } -const PluginListLabel: FC<PluginListLabelProps> = ({ name, frozen, hidden, version }) => { +const PluginListLabel: FC<PluginListLabelProps> = ({ name, frozen, hidden, version, disabled }) => { const { t } = useTranslation(); return ( <div style={{ display: 'flex', flexDirection: 'column', gap: '6px' }}> @@ -43,6 +44,20 @@ const PluginListLabel: FC<PluginListLabelProps> = ({ name, frozen, hidden, versi {t('PluginListLabel.hidden')} </div> )} + {disabled && ( + <div + style={{ + fontSize: '0.8rem', + color: '#dcdedf', + display: 'flex', + alignItems: 'center', + gap: '10px', + }} + > + <FaMoon /> + {t('PluginListLabel.disabled')} + </div> + )} </div> ); }; diff --git a/frontend/src/components/settings/pages/plugin_list/index.tsx b/frontend/src/components/settings/pages/plugin_list/index.tsx index da70f4ca..b21e4933 100644 --- a/frontend/src/components/settings/pages/plugin_list/index.tsx +++ b/frontend/src/components/settings/pages/plugin_list/index.tsx @@ -13,7 +13,7 @@ import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { FaDownload, FaEllipsisH, FaRecycle } from 'react-icons/fa'; -import { InstallType } from '../../../../plugin'; +import { enablePlugin, InstallType } from '../../../../plugin'; import { StorePluginVersion, getPluginList, @@ -84,9 +84,11 @@ function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> } {t('PluginListIndex.uninstall')} </MenuItem> {disabled ? - // implement enabler - <> - </> : + <MenuItem + onSelected={() => enablePlugin(name)} + > + {t('PluginListIndex.plugin_enable')} + </MenuItem> : <MenuItem onSelected={() => DeckyPluginLoader.disablePlugin( @@ -188,7 +190,8 @@ export default function PluginList({ isDeveloper }: { isDeveloper: boolean }) { const hidden = hiddenPlugins.includes(name); return { - label: <PluginListLabel name={name} frozen={frozen} hidden={hidden} version={version} />, + label: <PluginListLabel name={name} frozen={frozen} hidden={hidden} version={version} + disabled={disabled.find(p => p.name == name) !== undefined} />, position: pluginOrder.indexOf(name), data: { name, diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index 36766495..bf98cf6f 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -92,6 +92,7 @@ class PluginLoader extends Logger { DeckyBackend.addEventListener('loader/notify_updates', this.notifyUpdates.bind(this)); DeckyBackend.addEventListener('loader/import_plugin', this.importPlugin.bind(this)); DeckyBackend.addEventListener('loader/unload_plugin', this.unloadPlugin.bind(this)); + DeckyBackend.addEventListener('loader/disable_plugin', this.doDisablePlugin.bind(this)); DeckyBackend.addEventListener('loader/add_plugin_install_prompt', this.addPluginInstallPrompt.bind(this)); DeckyBackend.addEventListener( 'loader/add_multiple_plugins_install_prompt', @@ -207,10 +208,10 @@ class PluginLoader extends Logger { let registration: any; const uiMode = await new Promise( (r) => - (registration = SteamClient.UI.RegisterForUIModeChanged((mode: EUIMode) => { - r(mode); - registration.unregister(); - })), + (registration = SteamClient.UI.RegisterForUIModeChanged((mode: EUIMode) => { + r(mode); + registration.unregister(); + })), ); if (uiMode == EUIMode.GamePad) { // wait for SP window to exist before loading plugins @@ -384,6 +385,17 @@ class PluginLoader extends Logger { this.errorBoundaryHook.deinit(); } + public doDisablePlugin(name: string) { + const plugin = this.plugins.find((plugin) => plugin.name === name); + if (plugin == undefined) return; + + plugin?.onDismount?.(); + this.plugins = this.plugins.filter((p) => p !== plugin); + this.deckyState.setDisabledPlugins([...this.deckyState.publicState().disabled, + { name: plugin.name, version: plugin.version }]); + this.deckyState.setPlugins(this.plugins); + } + public unloadPlugin(name: string, skipStateUpdate: boolean = false) { const plugin = this.plugins.find((plugin) => plugin.name === name); plugin?.onDismount?.(); @@ -403,12 +415,15 @@ class PluginLoader extends Logger { return; } + this.deckyState.setDisabledPlugins(this.deckyState.publicState().disabled.filter(d => d.name !== name)) + try { if (useQueue) this.reloadLock = true; this.log(`Trying to load ${name}`); this.unloadPlugin(name, true); const startTime = performance.now(); + await this.importReactPlugin(name, version, loadType); const endTime = performance.now(); |
