diff options
| author | Travis Lane <63308171+Tormak9970@users.noreply.github.com> | 2023-04-03 17:21:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-03 14:21:31 -0700 |
| commit | 0f36e87ccea0d9bf2a3db8ee858f27d9d1b2d796 (patch) | |
| tree | e3018e7096401d387923f388637c5a45f6fa6185 /frontend/src/components/DeckyState.tsx | |
| parent | fd325ef1cc1d3e78b5e7686819e05606cc79d963 (diff) | |
| download | decky-loader-0f36e87ccea0d9bf2a3db8ee858f27d9d1b2d796.tar.gz decky-loader-0f36e87ccea0d9bf2a3db8ee858f27d9d1b2d796.zip | |
Add plugin reordering (#378)
* feat: started work on saving plugin order
* feat: implemented local ReorderableList
* feat: reoder complete except for usage of DFL
* switched to using dfl reorderableList
* fix: added missing file and removed frag
* updated to newest dfl
* Update defsettings.json
* fix: plugin order was missing on init
* fix: now await pluginOrder
* fix: moved the plugin-order load to plugin-loader
* chore: v6 and dfl bump
Diffstat (limited to 'frontend/src/components/DeckyState.tsx')
| -rw-r--r-- | frontend/src/components/DeckyState.tsx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/frontend/src/components/DeckyState.tsx b/frontend/src/components/DeckyState.tsx index 283fb118..67d4b78e 100644 --- a/frontend/src/components/DeckyState.tsx +++ b/frontend/src/components/DeckyState.tsx @@ -6,6 +6,7 @@ import { VerInfo } from '../updater'; interface PublicDeckyState { plugins: Plugin[]; + pluginOrder: string[]; activePlugin: Plugin | null; updates: PluginUpdateMapping | null; hasLoaderUpdate?: boolean; @@ -15,6 +16,7 @@ interface PublicDeckyState { export class DeckyState { private _plugins: Plugin[] = []; + private _pluginOrder: string[] = []; private _activePlugin: Plugin | null = null; private _updates: PluginUpdateMapping | null = null; private _hasLoaderUpdate: boolean = false; @@ -26,6 +28,7 @@ export class DeckyState { publicState(): PublicDeckyState { return { plugins: this._plugins, + pluginOrder: this._pluginOrder, activePlugin: this._activePlugin, updates: this._updates, hasLoaderUpdate: this._hasLoaderUpdate, @@ -44,6 +47,11 @@ export class DeckyState { this.notifyUpdate(); } + setPluginOrder(pluginOrder: string[]) { + this._pluginOrder = pluginOrder; + this.notifyUpdate(); + } + setActivePlugin(name: string) { this._activePlugin = this._plugins.find((plugin) => plugin.name === name) ?? null; this.notifyUpdate(); @@ -78,6 +86,7 @@ interface DeckyStateContext extends PublicDeckyState { setVersionInfo(versionInfo: VerInfo): void; setIsLoaderUpdating(hasUpdate: boolean): void; setActivePlugin(name: string): void; + setPluginOrder(pluginOrder: string[]): void; closeActivePlugin(): void; } @@ -106,10 +115,18 @@ export const DeckyStateContextProvider: FC<Props> = ({ children, deckyState }) = const setVersionInfo = (versionInfo: VerInfo) => deckyState.setVersionInfo(versionInfo); const setActivePlugin = (name: string) => deckyState.setActivePlugin(name); const closeActivePlugin = () => deckyState.closeActivePlugin(); + const setPluginOrder = (pluginOrder: string[]) => deckyState.setPluginOrder(pluginOrder); return ( <DeckyStateContext.Provider - value={{ ...publicDeckyState, setIsLoaderUpdating, setVersionInfo, setActivePlugin, closeActivePlugin }} + value={{ + ...publicDeckyState, + setIsLoaderUpdating, + setVersionInfo, + setActivePlugin, + closeActivePlugin, + setPluginOrder, + }} > {children} </DeckyStateContext.Provider> |
