From 0f36e87ccea0d9bf2a3db8ee858f27d9d1b2d796 Mon Sep 17 00:00:00 2001 From: Travis Lane <63308171+Tormak9970@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:21:31 -0400 Subject: 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 --- frontend/src/components/PluginView.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'frontend/src/components/PluginView.tsx') diff --git a/frontend/src/components/PluginView.tsx b/frontend/src/components/PluginView.tsx index 630cc962..3ecc2c86 100644 --- a/frontend/src/components/PluginView.tsx +++ b/frontend/src/components/PluginView.tsx @@ -7,17 +7,27 @@ import { scrollClasses, staticClasses, } from 'decky-frontend-lib'; -import { VFC } from 'react'; +import { VFC, useEffect, useState } from 'react'; +import { Plugin } from '../plugin'; import { useDeckyState } from './DeckyState'; import NotificationBadge from './NotificationBadge'; import { useQuickAccessVisible } from './QuickAccessVisibleState'; import TitleView from './TitleView'; const PluginView: VFC = () => { - const { plugins, updates, activePlugin, setActivePlugin, closeActivePlugin } = useDeckyState(); + const { plugins, updates, activePlugin, pluginOrder, setActivePlugin, closeActivePlugin } = useDeckyState(); const visible = useQuickAccessVisible(); + const [pluginList, setPluginList] = useState( + plugins.sort((a, b) => pluginOrder.indexOf(a.name) - pluginOrder.indexOf(b.name)), + ); + + useEffect(() => { + setPluginList(plugins.sort((a, b) => pluginOrder.indexOf(a.name) - pluginOrder.indexOf(b.name))); + console.log('updating PluginView after changes'); + }, [plugins, pluginOrder]); + if (activePlugin) { return ( @@ -36,7 +46,7 @@ const PluginView: VFC = () => {
- {plugins + {pluginList .filter((p) => p.content) .map(({ name, icon }) => ( -- cgit v1.2.3