feat(profile): Implement Optimistic UI for Profile Management#29
Merged
zakkiyyat merged 2 commits intoMixMatch-Inc:mainfrom Aug 31, 2025
Merged
feat(profile): Implement Optimistic UI for Profile Management#29zakkiyyat merged 2 commits intoMixMatch-Inc:mainfrom
zakkiyyat merged 2 commits intoMixMatch-Inc:mainfrom
Conversation
zakkiyyat
approved these changes
Aug 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14
Description
This pull request significantly enhances the user experience of the engineer profile page by implementing optimistic updates for all mutable fields (bio, anthem, photos).
When a user saves their changes, the UI now updates instantly, providing immediate feedback and making the application feel faster and more responsive. The actual API request happens in the background. In the rare case of a server error, the UI gracefully reverts to its original state and notifies the user, ensuring data integrity and a seamless experience.
Implementation Details
Optimistic Mutation Flow
TanStack Query: The core logic is managed by TanStack Query's
useMutationhook, which provides a robust framework for handling optimistic updates.Immediate UI Update (
onMutate):onMutatehandler is triggered.Error Handling & Rollback (
onError):onErrorhandler is executed.onMutateto roll back the local query data to its original state, seamlessly reverting the UI.Data Synchronization (
onSettled):onSettledhandler re-fetches the profile data to ensure the UI is perfectly synchronized with the server's state.How to Test
Happy Path (Successful Update)
Unhappy Path (API Failure & Rollback)