FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: sync relationship changes for users not in the local cache (#189) · stoatchat/javascript-client-sdk@119107b · GitHub

Commit 119107b

Browse files
authored
fix: sync relationship changes for users not in the local cache (#189)
UserRelationship events are re-dispatched as UserUpdate, which only applies changes to users already present in the collection (getOrPartial returns undefined for unknown ids when partials are disabled, the default). As a result, a relationship change (friend request accepted/received, block, unblock, etc.) made on another client is silently dropped on this client if it has never cached that user, until the next full resync. Ensure the user exists in the collection via getOrCreate using the data already included in the event, matching how Ready hydrates users on initial sync. Signed-off-by: aashish00021 <aashishbhardwaj07@icloud.com>
1 parent d435932 commit 119107b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/events/v1.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ export async function handleEvent(
905905
break;
906906
}
907907
case "UserRelationship": {
908+
// Live UserUpdate events are dropped for unknown users (see UserUpdate
909+
// below), so make sure this user exists in the cache before delegating.
910+
client.users.getOrCreate(event.user._id, event.user);
911+
908912
handleEvent(
909913
client,
910914
{

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL