feat: filter disconnected users
This commit is contained in:
parent
db5149ab5d
commit
4608e809b1
@ -882,17 +882,12 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
setCollaborators(sockets: string[]) {
|
setCollaborators(sockets: string[]) {
|
||||||
const collaborators: InstanceType<typeof Collab>["collaborators"] =
|
this.collaborators.forEach((value, key) => {
|
||||||
new Map();
|
if (value.socketId && !sockets.includes(value.socketId)) {
|
||||||
for (const socketId of sockets) {
|
this.collaborators.delete(key);
|
||||||
if (this.collaborators.has(socketId)) {
|
|
||||||
collaborators.set(socketId, this.collaborators.get(socketId)!);
|
|
||||||
} else {
|
|
||||||
collaborators.set(socketId, {});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
this.collaborators = collaborators;
|
this.excalidrawAPI.updateScene({ collaborators: this.collaborators });
|
||||||
this.excalidrawAPI.updateScene({ collaborators });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setLastBroadcastedOrReceivedSceneVersion = (version: number) => {
|
public setLastBroadcastedOrReceivedSceneVersion = (version: number) => {
|
||||||
|
@ -74,6 +74,9 @@ class Portal {
|
|||||||
/* syncAll */ true,
|
/* syncAll */ true,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
this.socket.on("room-user-change", (clients: string[]) => {
|
||||||
|
this.collab.setCollaborators(clients);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isOpen() {
|
isOpen() {
|
||||||
@ -193,6 +196,7 @@ class Portal {
|
|||||||
userState,
|
userState,
|
||||||
username: this.collab.state.username,
|
username: this.collab.state.username,
|
||||||
userId: this.collab.state.userId,
|
userId: this.collab.state.userId,
|
||||||
|
socketId: this.socket.id,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return this._broadcastSocketData(
|
return this._broadcastSocketData(
|
||||||
@ -216,6 +220,7 @@ class Portal {
|
|||||||
this.collab.excalidrawAPI.getAppState().selectedElementIds,
|
this.collab.excalidrawAPI.getAppState().selectedElementIds,
|
||||||
username: this.collab.state.username,
|
username: this.collab.state.username,
|
||||||
userId: this.collab.state.userId,
|
userId: this.collab.state.userId,
|
||||||
|
socketId: this.socket.id,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return this._broadcastSocketData(
|
return this._broadcastSocketData(
|
||||||
|
@ -111,6 +111,7 @@ export type SocketUpdateDataSource = {
|
|||||||
selectedElementIds: AppState["selectedElementIds"];
|
selectedElementIds: AppState["selectedElementIds"];
|
||||||
username: string;
|
username: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
|
socketId: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
IDLE_STATUS: {
|
IDLE_STATUS: {
|
||||||
@ -119,6 +120,7 @@ export type SocketUpdateDataSource = {
|
|||||||
userState: UserIdleState;
|
userState: UserIdleState;
|
||||||
username: string;
|
username: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
|
socketId: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -55,6 +55,7 @@ export type Collaborator = {
|
|||||||
avatarUrl?: string;
|
avatarUrl?: string;
|
||||||
// user id. If supplied, we'll filter out duplicates when rendering user avatars.
|
// user id. If supplied, we'll filter out duplicates when rendering user avatars.
|
||||||
id?: string;
|
id?: string;
|
||||||
|
socketId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DataURL = string & { _brand: "DataURL" };
|
export type DataURL = string & { _brand: "DataURL" };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user