sync update from LAN repo (source ji @ 85078a31)
This commit is contained in:
1 parent
5d6627af50
commit
e602d88695
864 files changed
+99150
-6346
No files matched your search
@@ -159,18 +159,32 @@ export function useSetSkillDisplay() {
|
||||
export function useEnableSkill() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
mutationFn: ({
|
||||
skillName,
|
||||
enabled,
|
||||
}: {
|
||||
skillName: string;
|
||||
enabled: boolean;
|
||||
}) => {
|
||||
await enableSkill(skillName, enabled);
|
||||
},
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: ["skills"] });
|
||||
},
|
||||
}) => enableSkill(skillName, enabled),
|
||||
onSuccess: (data, { skillName }) => {
|
||||
// The availability endpoint intentionally returns the filesystem skill
|
||||
// without ownership/tag annotations. Patch only the authoritative flag
|
||||
// so a fast cache update cannot erase richer list/detail metadata.
|
||||
queryClient.setQueryData<Skill>(["skill", skillName], (current) =>
|
||||
current ? { ...current, enabled: data.enabled } : current,
|
||||
);
|
||||
queryClient.setQueriesData<Skill[]>({ queryKey: ["skills"] }, (current) =>
|
||||
Array.isArray(current)
|
||||
? current.map((item) =>
|
||||
item.name === skillName
|
||||
? { ...item, enabled: data.enabled }
|
||||
: item,
|
||||
)
|
||||
: current,
|
||||
);
|
||||
void queryClient.invalidateQueries({ queryKey: ["skills"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["skill", skillName] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user