Skip to content

Commit

Permalink
Use deckyState in uninstall menu (fixes #98) (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
adntaha authored Jul 3, 2022
1 parent ee8aa98 commit 085aace
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def find_plugin_folder(self, name):
for folder in listdir(self.plugin_path):
with open(path.join(self.plugin_path, folder, 'plugin.json'), 'r') as f:
plugin = json.load(f)

if plugin['name'] == name:
return path.join(self.plugin_path, folder)
return path.join(self.plugin_path, folder)

async def uninstall_plugin(self, name):
tab = await get_tab("SP")
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/settings/pages/PluginList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { DialogButton, staticClasses } from 'decky-frontend-lib';
import { FaTrash } from 'react-icons/fa';

import { useDeckyState } from '../../DeckyState';

export default function PluginList() {
const plugins = window.DeckyPluginLoader?.getPlugins();
const { plugins } = useDeckyState();

if (plugins.length === 0) {
return (
Expand All @@ -14,7 +16,7 @@ export default function PluginList() {

return (
<ul style={{ listStyleType: 'none' }}>
{window.DeckyPluginLoader?.getPlugins().map(({ name }) => (
{plugins.map(({ name }) => (
<li style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<span>{name}</span>
<div className={staticClasses.Title} style={{ marginLeft: 'auto', boxShadow: 'none' }}>
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/plugin-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ class PluginLoader extends Logger {
});

this.routerHook.addRoute('/decky/store', () => <StorePage />);
this.routerHook.addRoute('/decky/settings', () => <SettingsPage />);
}

public getPlugins() {
return this.plugins;
this.routerHook.addRoute('/decky/settings', () => {
return (
<DeckyStateContextProvider deckyState={this.deckyState}>
<SettingsPage />
</DeckyStateContextProvider>
);
});
}

public addPluginInstallPrompt(artifact: string, version: string, request_id: string, hash: string) {
Expand Down

0 comments on commit 085aace

Please sign in to comment.