Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nzinfo committed Jan 1, 2025
1 parent 0a75715 commit 647317e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/collaboration/src/collaboratorspanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,19 @@ export class CollaboratorsPanel extends Panel {
private _onAwarenessChanged = () => {
const state = this._awareness.getStates() as any;
const collaborators: ICollaboratorAwareness[] = [];

const collaborators_keys: Set<string> = new Set();
state.forEach((value: Partial<ICollaboratorAwareness>, key: any) => {
if (
this._currentUser.isReady &&
value.user &&
value.user.username !== this._currentUser.identity!.username
) {
collaborators.push(value as ICollaboratorAwareness);
const uniqueKey = `${value.user.username}-${value.current || 'no-current'}`;

if (!collaborators_keys.has(uniqueKey)) {
collaborators.push(value as ICollaboratorAwareness);
collaborators_keys.add(uniqueKey);
}
}
});
this._collaboratorsChanged.emit(collaborators);
Expand All @@ -132,9 +137,11 @@ export function CollaboratorsBody(props: {

return (
<div className={COLLABORATORS_LIST_CLASS}>
{collaborators.map((collaborator, i) => {
{collaborators.map((collaborator) => {
const uniqueKey = `${collaborator.user.username}-${collaborator.current || 'no-current'}`;
return (
<Collaborator
key={uniqueKey}
collaborator={collaborator}
fileopener={props.fileopener}
docRegistry={props.docRegistry}
Expand Down

0 comments on commit 647317e

Please sign in to comment.