Skip to content

Commit 19df229

Browse files
committed
refactor: enhance type safety in Collab component
- Updated the type casting for user_id in the Collab component to ensure proper type handling of SocketId, improving code reliability and clarity.
1 parent 09a184f commit 19df229

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/frontend/src/lib/collab/Collab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PureComponent } from 'react';
1+
import { PureComponent } from 'react';
22
import type { ExcalidrawImperativeAPI, AppState, SocketId, Collaborator as ExcalidrawCollaboratorType } from '@atyrode/excalidraw/types';
33
import type { ExcalidrawElement as ExcalidrawElementType } from '@atyrode/excalidraw/element/types';
44
import {
@@ -490,13 +490,13 @@ class Collab extends PureComponent<CollabProps, CollabState> {
490490
if (messageData.button) pointerDataIn.button = messageData.button;
491491
this.setState(prevState => {
492492
const newCollaborators = new Map(prevState.collaborators);
493-
const existing = newCollaborators.get(user_id);
493+
const existing = newCollaborators.get(user_id as SocketId);
494494
const updatedCollaborator: Collaborator = {
495495
...(existing as Collaborator),
496496
pointer: pointerDataIn,
497497
button: pointerDataIn.button
498498
};
499-
newCollaborators.set(user_id, updatedCollaborator);
499+
newCollaborators.set(user_id as SocketId, updatedCollaborator);
500500
return { collaborators: newCollaborators };
501501
});
502502
break;

0 commit comments

Comments
 (0)