From ca40caaad8c341983205f781058600d4c40e40a8 Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Tue, 6 Feb 2024 07:21:38 -0800 Subject: [PATCH] don't broadcast null userIds --- .../automerge-repo-react-hooks/src/useLocalAwareness.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/automerge-repo-react-hooks/src/useLocalAwareness.ts b/packages/automerge-repo-react-hooks/src/useLocalAwareness.ts index 0bd3e7e55..ba1e82c34 100644 --- a/packages/automerge-repo-react-hooks/src/useLocalAwareness.ts +++ b/packages/automerge-repo-react-hooks/src/useLocalAwareness.ts @@ -47,6 +47,12 @@ export const useLocalAwareness = ({ } useEffect(() => { + // Don't broadcast if userId isn't set: this avoids bogus broadcasts + // during the loading of a userId document. + if (!userId) { + return + } + // Send periodic heartbeats const heartbeat = () => void handle.broadcast([userId, localStateRef.current])