Skip to content

Commit

Permalink
chore(developer): refetch keys after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed May 14, 2024
1 parent 8bbe6a2 commit b70df06
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/developer/src/components/page/CreateKey.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export function Component() {
const loaderData = useLoaderData();
const functions = useFunctions();
const createKey = httpsCallable(functions, 'createKey');
const getKeys = httpsCallable(functions, 'keys');

const queryClient = useQueryClient();
const {
Expand All @@ -103,10 +104,13 @@ export function Component() {
} = useMutation({
mutationFn: (data) => Spinner.minDelay(createKey(data)),
onSuccess: async () => {
await queryClient.cancelQueries();
await queryClient.cancelQueries({
queryKey: ['my keys'],
});

queryClient.invalidateQueries({
queryKey: ['my keys', loaderData.user.uid],
await queryClient.refetchQueries({
queryKey: ['my keys'],
queryFn: () => getKeys(),
});
},
});
Expand Down

0 comments on commit b70df06

Please sign in to comment.