Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [M3-8589] - Flickering on the user profile page when updating the currently signed in user's username #10947

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading