Skip to content

Commit 12fb50a

Browse files
committed
fix(credential-groups): await the refetch before clearing the edit buffer
The update mutation fired its invalidations without returning them, so mutateAsync resolved before the refetch landed. Callers that clear their draft on success then fell back onto the pre-save cache and flashed the old name and description until the refetch completed — or kept showing them if it failed.
1 parent 522b3f5 commit 12fb50a

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

apps/sim/hooks/queries/credential-groups.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,18 @@ export function useUpdateCredentialGroup() {
104104
params: { id: workspaceId, groupId },
105105
body,
106106
}),
107-
onSettled: (_data, _error, variables) => {
108-
queryClient.invalidateQueries({ queryKey: credentialGroupKeys.list(variables.workspaceId) })
109-
queryClient.invalidateQueries({
110-
queryKey: credentialGroupKeys.detail(variables.workspaceId, variables.groupId),
111-
})
112-
},
107+
// Returned so `mutateAsync` resolves only once the refetch has landed. Callers
108+
// clear their edit buffer on success, which would otherwise fall back onto the
109+
// pre-save cache and flash the old values.
110+
onSettled: (_data, _error, variables) =>
111+
Promise.all([
112+
queryClient.invalidateQueries({
113+
queryKey: credentialGroupKeys.list(variables.workspaceId),
114+
}),
115+
queryClient.invalidateQueries({
116+
queryKey: credentialGroupKeys.detail(variables.workspaceId, variables.groupId),
117+
}),
118+
]),
113119
})
114120
}
115121

0 commit comments

Comments
 (0)