diff options
| author | Jesse Bofill <jesse_bofill@yahoo.com> | 2025-10-06 13:50:02 -0600 |
|---|---|---|
| committer | Jesse Bofill <jesse_bofill@yahoo.com> | 2025-10-06 13:50:02 -0600 |
| commit | 65f1eb052de17f21144571d932281a0484f48dfd (patch) | |
| tree | 62838c5fb5e86d0896b78b376abede9103b14e39 | |
| parent | 86b5567d4eac84399245c9a71270d6142ee54ded (diff) | |
| download | decky-loader-65f1eb052de17f21144571d932281a0484f48dfd.tar.gz decky-loader-65f1eb052de17f21144571d932281a0484f48dfd.zip | |
implement base frontend changes necessary for plugin disabling
| -rw-r--r-- | frontend/src/components/DeckyState.tsx | 15 | ||||
| -rw-r--r-- | frontend/src/components/settings/pages/plugin_list/index.tsx | 11 | ||||
| -rw-r--r-- | frontend/src/components/store/PluginCard.tsx | 4 | ||||
| -rw-r--r-- | frontend/src/components/store/Store.tsx | 2 | ||||
| -rw-r--r-- | frontend/src/plugin-loader.tsx | 14 | ||||
| -rw-r--r-- | frontend/src/plugin.ts | 2 |
6 files changed, 35 insertions, 13 deletions
diff --git a/frontend/src/components/DeckyState.tsx b/frontend/src/components/DeckyState.tsx index d2ac63ae..b2f7ac33 100644 --- a/frontend/src/components/DeckyState.tsx +++ b/frontend/src/components/DeckyState.tsx @@ -1,12 +1,14 @@ import { FC, ReactNode, createContext, useContext, useEffect, useState } from 'react'; import { DEFAULT_NOTIFICATION_SETTINGS, NotificationSettings } from '../notification-service'; -import { Plugin } from '../plugin'; +import { DisabledPlugin, Plugin } from '../plugin'; import { PluginUpdateMapping } from '../store'; import { VerInfo } from '../updater'; interface PublicDeckyState { plugins: Plugin[]; + disabled: DisabledPlugin[]; + installedPlugins: (Plugin | DisabledPlugin)[]; pluginOrder: string[]; frozenPlugins: string[]; hiddenPlugins: string[]; @@ -26,6 +28,8 @@ export interface UserInfo { export class DeckyState { private _plugins: Plugin[] = []; + private _disabledPlugins: DisabledPlugin[] = []; + private _installedPlugins: (Plugin | DisabledPlugin)[] = []; private _pluginOrder: string[] = []; private _frozenPlugins: string[] = []; private _hiddenPlugins: string[] = []; @@ -42,6 +46,8 @@ export class DeckyState { publicState(): PublicDeckyState { return { plugins: this._plugins, + disabled: this._disabledPlugins, + installedPlugins: this._disabledPlugins, pluginOrder: this._pluginOrder, frozenPlugins: this._frozenPlugins, hiddenPlugins: this._hiddenPlugins, @@ -62,6 +68,13 @@ export class DeckyState { setPlugins(plugins: Plugin[]) { this._plugins = plugins; + this._installedPlugins = [...plugins, ...this._disabledPlugins]; + this.notifyUpdate(); + } + + setDisabledPlugins(disabledPlugins: DisabledPlugin[]) { + this._disabledPlugins = disabledPlugins; + this._installedPlugins = [...this._plugins, ...disabledPlugins]; this.notifyUpdate(); } diff --git a/frontend/src/components/settings/pages/plugin_list/index.tsx b/frontend/src/components/settings/pages/plugin_list/index.tsx index 9a7cb076..e244b8a9 100644 --- a/frontend/src/components/settings/pages/plugin_list/index.tsx +++ b/frontend/src/components/settings/pages/plugin_list/index.tsx @@ -147,10 +147,11 @@ type PluginData = { }; export default function PluginList({ isDeveloper }: { isDeveloper: boolean }) { - const { plugins, updates, pluginOrder, setPluginOrder, frozenPlugins, hiddenPlugins } = useDeckyState(); + const { installedPlugins, updates, pluginOrder, setPluginOrder, frozenPlugins, hiddenPlugins } = useDeckyState(); + const [_, setPluginOrderSetting] = useSetting<string[]>( 'pluginOrder', - plugins.map((plugin) => plugin.name), + installedPlugins.map((plugin) => plugin.name), ); const { t } = useTranslation(); @@ -164,7 +165,7 @@ export default function PluginList({ isDeveloper }: { isDeveloper: boolean }) { useEffect(() => { setPluginEntries( - plugins.map(({ name, version }) => { + installedPlugins.map(({ name, version }) => { const frozen = frozenPlugins.includes(name); const hidden = hiddenPlugins.includes(name); @@ -186,9 +187,9 @@ export default function PluginList({ isDeveloper }: { isDeveloper: boolean }) { }; }), ); - }, [plugins, updates, hiddenPlugins]); + }, [installedPlugins, updates, hiddenPlugins]); - if (plugins.length === 0) { + if (installedPlugins.length === 0) { return ( <div> <p>{t('PluginListIndex.no_plugin')}</p> diff --git a/frontend/src/components/store/PluginCard.tsx b/frontend/src/components/store/PluginCard.tsx index f64abd09..243f846f 100644 --- a/frontend/src/components/store/PluginCard.tsx +++ b/frontend/src/components/store/PluginCard.tsx @@ -3,13 +3,13 @@ import { CSSProperties, FC, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { FaArrowDown, FaArrowUp, FaCheck, FaDownload, FaRecycle } from 'react-icons/fa'; -import { InstallType, Plugin } from '../../plugin'; +import { DisabledPlugin, InstallType, Plugin } from '../../plugin'; import { StorePlugin, requestPluginInstall } from '../../store'; import ExternalLink from '../ExternalLink'; interface PluginCardProps { storePlugin: StorePlugin; - installedPlugin: Plugin | undefined; + installedPlugin: Plugin | DisabledPlugin | undefined; } const PluginCard: FC<PluginCardProps> = ({ storePlugin, installedPlugin }) => { diff --git a/frontend/src/components/store/Store.tsx b/frontend/src/components/store/Store.tsx index 3209ba08..72187cbc 100644 --- a/frontend/src/components/store/Store.tsx +++ b/frontend/src/components/store/Store.tsx @@ -105,7 +105,7 @@ const BrowseTab: FC<{ setPluginCount: Dispatch<SetStateAction<number | null>> }> })(); }, []); - const { plugins: installedPlugins } = useDeckyState(); + const { installedPlugins } = useDeckyState(); return ( <> diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index df0a6956..9d74cbae 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -30,7 +30,7 @@ import { FrozenPluginService } from './frozen-plugins-service'; import { HiddenPluginsService } from './hidden-plugins-service'; import Logger from './logger'; import { NotificationService } from './notification-service'; -import { InstallType, Plugin, PluginLoadType } from './plugin'; +import { DisabledPlugin, InstallType, Plugin, PluginLoadType } from './plugin'; import RouterHook from './router-hook'; import { deinitSteamFixes, initSteamFixes } from './steamfixes'; import { checkForPluginUpdates } from './store'; @@ -197,7 +197,7 @@ class PluginLoader extends Logger { private getPluginsFromBackend = DeckyBackend.callable< [], - { name: string; version: string; load_type: PluginLoadType }[] + { name: string; version: string; load_type: PluginLoadType; disabled: boolean }[] >('loader/get_plugins'); private restartWebhelper = DeckyBackend.callable<[], void>('utilities/restart_webhelper'); @@ -220,10 +220,16 @@ class PluginLoader extends Logger { this.runCrashChecker(); const plugins = await this.getPluginsFromBackend(); const pluginLoadPromises = []; + const disabledPlugins: DisabledPlugin[] = []; const loadStart = performance.now(); for (const plugin of plugins) { - if (!this.hasPlugin(plugin.name)) - pluginLoadPromises.push(this.importPlugin(plugin.name, plugin.version, plugin.load_type, false)); + if (plugin.disabled) { + disabledPlugins.push({ name: plugin.name, version: plugin.version }); + this.deckyState.setDisabledPlugins(disabledPlugins); + } else { + if (!this.hasPlugin(plugin.name)) + pluginLoadPromises.push(this.importPlugin(plugin.name, plugin.version, plugin.load_type, false)); + } } await Promise.all(pluginLoadPromises); const loadEnd = performance.now(); diff --git a/frontend/src/plugin.ts b/frontend/src/plugin.ts index 0035990e..f53118b2 100644 --- a/frontend/src/plugin.ts +++ b/frontend/src/plugin.ts @@ -14,6 +14,8 @@ export interface Plugin { titleView?: JSX.Element; } +export type DisabledPlugin = Pick<Plugin, 'name' | 'version'>; + export enum InstallType { INSTALL, REINSTALL, |
