File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed
apps/frontend/src/features/canvas/ui/CollaborativeCursors Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -14,22 +14,21 @@ export function CollaborativeCursors({ cursors }: CollaborativeCursorsProps) {
1414 const { flowToScreenPosition } = useReactFlow ( ) ;
1515 const { currentUser } = useUserStore ( ) ;
1616 const validCursors = useMemo ( ( ) => {
17- const filteredCursors = Array . from ( cursors . values ( ) ) . filter (
18- ( cursor ) =>
19- cursor . cursor &&
20- ( cursor . clientId as unknown as string ) !== currentUser . clientId ,
21- ) ;
22-
23- const uniqueCursors = filteredCursors . reduce ( ( acc , current ) => {
24- const exists = acc . find ( ( item ) => item . clientId === current . clientId ) ;
25- if ( ! exists ) {
26- acc . push ( current ) ;
17+ const seen = new Set < string > ( ) ;
18+ return Array . from ( cursors . values ( ) ) . filter ( ( cursor ) => {
19+ if (
20+ ! cursor . cursor ||
21+ ( cursor . clientId as unknown as string ) === currentUser . clientId
22+ ) {
23+ return false ;
2724 }
28- return acc ;
29- } , [ ] as AwarenessState [ ] ) ;
30-
31- return uniqueCursors ;
32- } , [ cursors ] ) ;
25+ if ( seen . has ( cursor . clientId ) ) {
26+ return false ;
27+ }
28+ seen . add ( cursor . clientId ) ;
29+ return true ;
30+ } ) ;
31+ } , [ cursors , currentUser . clientId ] ) ;
3332
3433 return (
3534 < Panel >
You can’t perform that action at this time.
0 commit comments