feat: filter disconnected users

This commit is contained in:
Arnošt Pleskot 2023-07-13 10:07:31 +02:00
parent db5149ab5d
commit 4608e809b1
No known key found for this signature in database
4 changed files with 13 additions and 10 deletions

View file

@ -882,17 +882,12 @@ class Collab extends PureComponent<Props, CollabState> {
};
setCollaborators(sockets: string[]) {
const collaborators: InstanceType<typeof Collab>["collaborators"] =
new Map();
for (const socketId of sockets) {
if (this.collaborators.has(socketId)) {
collaborators.set(socketId, this.collaborators.get(socketId)!);
} else {
collaborators.set(socketId, {});
this.collaborators.forEach((value, key) => {
if (value.socketId && !sockets.includes(value.socketId)) {
this.collaborators.delete(key);
}
}
this.collaborators = collaborators;
this.excalidrawAPI.updateScene({ collaborators });
});
this.excalidrawAPI.updateScene({ collaborators: this.collaborators });
}
public setLastBroadcastedOrReceivedSceneVersion = (version: number) => {