tldraw/components/canvas/coop/coop.tsx

30 lines
825 B
TypeScript
Raw Normal View History

2021-06-30 20:31:29 +00:00
import Cursor from './cursor'
import { useCoopSelector } from 'state/coop/coop-state'
2021-06-30 20:56:42 +00:00
import { useSelector } from 'state'
2021-06-30 20:31:29 +00:00
export default function Presence(): JSX.Element {
const others = useCoopSelector((s) => s.data.others)
2021-06-30 20:56:42 +00:00
const currentPageId = useSelector((s) => s.data.currentPageId)
2021-06-30 20:31:29 +00:00
if (!others) return null
2021-06-30 20:31:29 +00:00
return (
<>
{Object.values(others)
.filter(({ presence }) => presence?.pageId === currentPageId)
.map(({ connectionId, presence }) => {
return (
<Cursor
key={`cursor-${connectionId}`}
color={'red'}
duration={presence.duration}
times={presence.times}
bufferedXs={presence.bufferedXs}
bufferedYs={presence.bufferedYs}
/>
)
})}
2021-06-30 20:31:29 +00:00
</>
)
}