fix: sync profile avatar across open tabs via localStorage#557
Open
saurabhhhcodes wants to merge 1 commit into
Open
fix: sync profile avatar across open tabs via localStorage#557saurabhhhcodes wants to merge 1 commit into
saurabhhhcodes wants to merge 1 commit into
Conversation
Use the storage event to propagate avatar URL changes to all open tabs. When a user updates their avatar in Profile settings, the new URL is written to localStorage. Other tabs detect the change via the window 'storage' event and update userData state immediately. Closes indresh404#550
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Description
Fixes #550
The profile avatar doesn't update in other open tabs after being changed in settings.
Root Cause
The existing
onSnapshotlistener on the Firestore user document should handle cross-tab sync, but Firestore's local IndexedDB cache (shared across tabs in the same origin) can suppress the real-time callback when the cache is updated from another tab's write.Fix
rh_avatar_${uid})windowstorageevent. When a cross-tab avatar change is detected, updateuserDatastate immediatelyThis pattern uses the browser's built-in cross-tab communication mechanism (
storageevents fire automatically in other tabs when localStorage changes) without requiring any external API.Testing