refactor(openclaw): migrate config panels to TanStack Query hooks

Centralize query keys and extract reusable hooks (useOpenClaw.ts),
replacing manual useState/useEffect load/save patterns in Env, Tools,
and AgentsDefaults panels for consistency with MCP/Skills modules.
This commit is contained in:
Jason
2026-02-08 15:35:09 +08:00
parent bc87f9d9eb
commit 00b424628f
8 changed files with 228 additions and 120 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ import { providersApi, settingsApi, type AppId } from "@/lib/api";
import type { Provider, Settings } from "@/types";
import { extractErrorMessage } from "@/utils/errorUtils";
import { generateUUID } from "@/utils/uuid";
import { openclawKeys } from "@/hooks/useOpenClaw";
export const useAddProviderMutation = (appId: AppId) => {
const queryClient = useQueryClient();
@@ -185,10 +186,10 @@ export const useSwitchProviderMutation = (appId: AppId) => {
}
if (appId === "openclaw") {
await queryClient.invalidateQueries({
queryKey: ["openclawLiveProviderIds"],
queryKey: openclawKeys.liveProviderIds,
});
await queryClient.invalidateQueries({
queryKey: ["openclawDefaultModel"],
queryKey: openclawKeys.defaultModel,
});
}