From 901156526c6e10c6573ec4bf614a4460a074b52a Mon Sep 17 00:00:00 2001 From: Lukas Remis Date: Fri, 25 Sep 2026 19:41:25 +0200 Subject: [PATCH] Settings: reopening the signature editor showed the old signature Saving invalidated only the ["accounts"] list, not the ["account", id] detail the editors read. Reopening rendered the stale cached detail, and the rich-text editor seeds its content only once on mount, so the refetch that followed never reached the screen. Both the signature and the account editors now write the PATCH response into the detail cache. Co-Authored-By: Claude Opus 5.5 --- frontend/src/routes/settings/Settings.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/settings/Settings.tsx b/frontend/src/routes/settings/Settings.tsx index 6957bb3..8fa3cc0 100644 --- a/frontend/src/routes/settings/Settings.tsx +++ b/frontend/src/routes/settings/Settings.tsx @@ -389,6 +389,7 @@ function AccountEditor({ onSaved: () => void; }) { const t = useT(); + const queryClient = useQueryClient(); const detail = useQuery({ queryKey: ["account", accountId], queryFn: () => api.accountDetail(accountId) }); const [displayName, setDisplayName] = useState(""); const [color, setColor] = useState("#888888"); @@ -428,7 +429,10 @@ function AccountEditor({ } return api.updateAccount(accountId, patch); }, - onSuccess: onSaved, + onSuccess: (updated) => { + queryClient.setQueryData(["account", accountId], updated); + onSaved(); + }, onError: (e) => setError(e instanceof ApiError ? e.message : "Save failed"), }); @@ -519,6 +523,7 @@ function SignatureEditor({ onSaved: () => void; }) { const t = useT(); + const queryClient = useQueryClient(); const detail = useQuery({ queryKey: ["account", accountId], queryFn: () => api.accountDetail(accountId), @@ -532,7 +537,12 @@ function SignatureEditor({ const save = useMutation({ mutationFn: () => api.updateAccount(accountId, { signature }), - onSuccess: onSaved, + // Keep the cached detail current: the editor seeds from it only once on mount, + // so a stale entry would reopen the editor with the old (e.g. empty) signature. + onSuccess: (updated) => { + queryClient.setQueryData(["account", accountId], updated); + onSaved(); + }, onError: (e) => setError(e instanceof ApiError ? e.message : "Save failed"), });