Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core-data/src/awareness/awareness-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export abstract class AwarenessState<

this.hasSetupRun = true;

this.onSetUp();

this.on(
'change',
( { added, removed, updated }: AwarenessStateChange ) => {
Expand All @@ -186,8 +188,6 @@ export abstract class AwarenessState<
this.updateSubscribers();
}
);

this.onSetUp();
};

/**
Expand Down
12 changes: 10 additions & 2 deletions packages/sync/src/providers/http-polling/polling-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as Y from 'yjs';
import * as encoding from 'lib0/encoding';
import * as decoding from 'lib0/decoding';
import type { Awareness } from 'y-protocols/awareness';
import { removeAwarenessStates } from 'y-protocols/awareness';
import * as syncProtocol from 'y-protocols/sync';

/**
Expand Down Expand Up @@ -162,15 +163,22 @@ function processAwarenessUpdate(
}
} );

if ( added.size + updated.size + removed.size > 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we still want to emit change when a user is removed?

Copy link
Contributor Author

@ingeniumed ingeniumed Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method that I called within AwarenessProtocol handles that, hence why it's not needed.

https://github.com/yjs/y-protocols/blob/master/awareness.js#L189

if ( added.size + updated.size > 0 ) {
awareness.emit( 'change', [
{
added: Array.from( added ),
updated: Array.from( updated ),
removed: Array.from( removed ),
},
] );
}

if ( removed.size > 0 ) {
removeAwarenessStates(
awareness,
Array.from( removed ),
POLLING_MANAGER_ORIGIN
);
}
}

/**
Expand Down
Loading