@@ -5,6 +5,7 @@ import { useReactFlow, type XYPosition } from "@xyflow/react";
55
66import { createSocketIOProvider } from "@/shared/api/socketProvider" ;
77import { useUserStore } from "@/entities/user/model/userStore" ;
8+ import { useWorkspace } from "@/shared/lib/useWorkspace" ;
89
910export interface AwarenessState {
1011 cursor : XYPosition | null ;
@@ -14,13 +15,9 @@ export interface AwarenessState {
1415
1516interface CollaborativeCursorsProps {
1617 ydoc : Y . Doc ;
17- roomName ?: string ;
1818}
1919
20- export function useCollaborativeCursors ( {
21- ydoc,
22- roomName = "cursor-room" ,
23- } : CollaborativeCursorsProps ) {
20+ export function useCollaborativeCursors ( { ydoc } : CollaborativeCursorsProps ) {
2421 const flowInstance = useReactFlow ( ) ;
2522 const provider = useRef < SocketIOProvider > ( ) ;
2623 const [ cursors , setCursors ] = useState < Map < number , AwarenessState > > (
@@ -29,8 +26,10 @@ export function useCollaborativeCursors({
2926 const { currentUser } = useUserStore ( ) ;
3027 const { color, clientId } = currentUser ;
3128
29+ const workspace = useWorkspace ( ) ;
30+
3231 useEffect ( ( ) => {
33- const wsProvider = createSocketIOProvider ( " flow-room" , ydoc ) ;
32+ const wsProvider = createSocketIOProvider ( ` flow-room- ${ workspace } ` , ydoc ) ;
3433 provider . current = wsProvider ;
3534
3635 wsProvider . awareness . setLocalState ( {
@@ -53,7 +52,7 @@ export function useCollaborativeCursors({
5352 return ( ) => {
5453 wsProvider . destroy ( ) ;
5554 } ;
56- } , [ ydoc , roomName , color , clientId ] ) ;
55+ } , [ ydoc , color , clientId , workspace ] ) ;
5756
5857 const updateCursorPosition = useCallback (
5958 ( x : number | null , y : number | null ) => {
0 commit comments