Fixed bugs in Plugin settings pane

This commit is contained in:
Gregory Schier
2025-07-20 08:28:00 -07:00
parent 861b41b5ae
commit 86f23990eb
7 changed files with 146 additions and 105 deletions

View File

@@ -6,18 +6,21 @@ import { useAtomValue } from 'jotai';
import { queryClient } from '../lib/queryClient';
import { invokeCmd } from '../lib/tauri';
function pluginInfoKey(id: string, plugin: Plugin | null) {
return ['plugin_info', id, plugin?.updatedAt ?? 'n/a'];
function pluginInfoKey(id: string | null, plugin: Plugin | null) {
return ['plugin_info', id ?? 'n/a', plugin?.updatedAt ?? 'n/a'];
}
export function usePluginInfo(id: string) {
export function usePluginInfo(id: string | null) {
const plugins = useAtomValue(pluginsAtom);
// Get the plugin so we can refetch whenever it's updated
const plugin = plugins.find((p) => p.id === id);
return useQuery({
queryKey: pluginInfoKey(id, plugin ?? null),
placeholderData: (prev) => prev, // Keep previous data on refetch
queryFn: () => invokeCmd<PluginMetadata>('cmd_plugin_info', { id }),
queryFn: () => {
if (id == null) return null;
return invokeCmd<PluginMetadata>('cmd_plugin_info', { id });
},
});
}