Skip to content

Commit

Permalink
fix: [M3-8589] - Flickering on the user profile page when updating th…
Browse files Browse the repository at this point in the history
…e currently signed in user's username (#10947)

* update the profile cache manually rather than doing an invalidation

* Added changeset: Flickering on the user profile page when updating the currently signed in user's username

---------

Co-authored-by: Banks Nussman <banks@nussman.us>
  • Loading branch information
bnussman-akamai and bnussman authored Sep 17, 2024
1 parent 44763ea commit 63ae19a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10947-fixed-1726507951785.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Flickering on the user profile page when updating the currently signed in user's username ([#10947](https://github.com/linode/manager/pull/10947))
18 changes: 14 additions & 4 deletions packages/manager/src/queries/account/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
Filter,
Grants,
Params,
Profile,
ResourcePage,
User,
} from '@linode/api-v4';
Expand Down Expand Up @@ -65,11 +66,20 @@ export const useUpdateUserMutation = (username: string) => {
accountQueries.users._ctx.user(user.username).queryKey,
user
);
// If the currently logged in user updates their user

// If the currently logged in user updates their user, we need to update the profile
// query to reflect the latest data.
if (username === profile?.username) {
queryClient.invalidateQueries({
queryKey: profileQueries.profile().queryKey,
});
queryClient.setQueryData<Profile>(
profileQueries.profile().queryKey,
(oldProfile) => {
if (!oldProfile) {
return;
}

return { ...oldProfile, ...user };
}
);
}
},
});
Expand Down

0 comments on commit 63ae19a

Please sign in to comment.