fix(settings): update cache immediately on save instead of invalidating

Using setQueryData with the PATCH response means jira_token_set is
reflected in the UI instantly — no extra GET round-trip that could
leave the badge stale.
This commit is contained in:
kitos
2026-05-26 17:20:40 +02:00
parent 1f08eb014b
commit aaa344ab79
+4 -3
View File
@@ -834,10 +834,11 @@ function ProfileSection() {
const saveMut = useMutation({ const saveMut = useMutation({
mutationFn: updateMyPreferences, mutationFn: updateMyPreferences,
onSuccess: () => { onSuccess: (updatedMe) => {
qc.invalidateQueries({ queryKey: ["me-prefs"] }); // Update cache immediately with the response — no extra round-trip needed
qc.setQueryData(["me-prefs"], updatedMe);
setDirty(false); setDirty(false);
setJiraApiToken(""); // clear token field after save — it's now persisted setJiraApiToken(""); // clear token field after save — it's persisted
setToast({ msg: "Profile settings saved", type: "success" }); setToast({ msg: "Profile settings saved", type: "success" });
}, },
onError: () => setToast({ msg: "Failed to save", type: "error" }), onError: () => setToast({ msg: "Failed to save", type: "error" }),