File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
apps/frontend/src/features/canvas/ui/CollaborativeCursors Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,23 @@ interface CollaborativeCursorsProps {
1313export function CollaborativeCursors ( { cursors } : CollaborativeCursorsProps ) {
1414 const { flowToScreenPosition } = useReactFlow ( ) ;
1515 const { currentUser } = useUserStore ( ) ;
16- const validCursors = useMemo (
17- ( ) =>
18- Array . from ( cursors . values ( ) ) . filter (
19- ( cursor ) =>
20- cursor . cursor &&
21- ( cursor . clientId as unknown as string ) !== currentUser . clientId ,
22- ) ,
23- [ cursors ] ,
24- ) ;
16+ 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 ) ;
27+ }
28+ return acc ;
29+ } , [ ] as AwarenessState [ ] ) ;
30+
31+ return uniqueCursors ;
32+ } , [ cursors ] ) ;
2533
2634 return (
2735 < Panel >
You can’t perform that action at this time.
0 commit comments