Previously, if the user accessed their own profile, in order to avoid a fetch, the app set the user's data (which is fetched by the entire application on login) as the profile data. When a user would update their username, the UserProfilePage would correctly re-fetch the user object and set that as the user. However, on any load of the page that didn't fully reload the app, the component would re-set the authenticated user's (now stale) data as the profile, causing it to appear that the username didn't change.
These changes simplify the UserProfilePage component a bit, treating one's own user profile data (except anything sensitive) the same way another user's data would be treated, with a fetch on component load, enabling the post-username-change fetch to work properly and making the component slightly more maintainable.
Description
Fixes #1655.
Changes
Previously, if the user accessed their own profile, in order to avoid a fetch, the app set the user's data (which is fetched by the entire application on login) as the profile data. When a user would update their username, the UserProfilePage would correctly re-fetch the user object and set that as the user. However, on any load of the page that didn't fully reload the app, the component would re-set the authenticated user's (now stale) data as the profile, causing it to appear that the username didn't change.
These changes simplify the UserProfilePage component a bit, treating one's own user profile data (except anything sensitive) the same way another user's data would be treated, with a fetch on component load, enabling the post-username-change fetch to work properly and making the component slightly more maintainable.
Screenshots
A video of the changes in action is available below. https://github.com/PolicyEngine/policyengine-app/assets/14987227/8a5b1641-4b75-4656-9453-fd17779c07e6
Tests
None have been added.