From 513a7b488b80028473e89d74ffc92323eb33fcac Mon Sep 17 00:00:00 2001 From: kitos Date: Tue, 26 May 2026 17:20:40 +0200 Subject: [PATCH] fix(settings): update cache immediately on save instead of invalidating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/SettingsPage.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index ad6e49b..5c5029f 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -834,10 +834,11 @@ function ProfileSection() { const saveMut = useMutation({ mutationFn: updateMyPreferences, - onSuccess: () => { - qc.invalidateQueries({ queryKey: ["me-prefs"] }); + onSuccess: (updatedMe) => { + // Update cache immediately with the response — no extra round-trip needed + qc.setQueryData(["me-prefs"], updatedMe); 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" }); }, onError: () => setToast({ msg: "Failed to save", type: "error" }),