mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
19 lines
569 B
TypeScript
19 lines
569 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { useCollaboration } from '@/app/components/workflow/collaboration'
|
|
|
|
export function useCollaborativeCursors(appId: string) {
|
|
const { cursors, isConnected } = useCollaboration(appId)
|
|
const [myUserId, setMyUserId] = useState<string | null>(null)
|
|
|
|
useEffect(() => {
|
|
if (isConnected)
|
|
setMyUserId('current-user')
|
|
}, [isConnected])
|
|
|
|
const filteredCursors = Object.fromEntries(
|
|
Object.entries(cursors).filter(([userId]) => userId !== myUserId),
|
|
)
|
|
|
|
return { cursors: filteredCursors, myUserId }
|
|
}
|