Skip to content

Commit

Permalink
fix: presence calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Feb 16, 2024
1 parent d2627f7 commit 6fe7f65
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@milkdown/react": "7.3.3",
"@milkdown/transformer": "7.3.3",
"@milkdown/utils": "7.3.3",
"@mx-space/api-client": "1.8.0-beta.0",
"@mx-space/api-client": "1.8.0-beta.1",
"@prosemirror-adapter/react": "0.2.6",
"@radix-ui/react-dialog": "1.0.5",
"@radix-ui/react-label": "2.0.2",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions src/app/(app)/web-dev/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { apiClient } from '~/lib/request'
import { usePageScrollLocation } from '~/providers/root/page-scroll-info-provider'
import { queries } from '~/queries/definition'
import { socketClient } from '~/socket'
import { EventTypes, SocketEmitEnum } from '~/types/events'
import { SocketEmitEnum } from '~/types/events'

export default () => {
const roomName = useMemo(() => `article-${111112222}`, [])
Expand All @@ -44,22 +44,10 @@ export default () => {
roomName,
})

const handler = (e: any) => {
console.log(e, 'EventTypes.ACTIVITY_UPDATE_PRESENCE')
}
window.addEventListener(
`event:${EventTypes.ACTIVITY_UPDATE_PRESENCE}`,
handler,
)

return () => {
socketClient.emit(SocketEmitEnum.Leave, {
roomName,
})
window.removeEventListener(
`event:${EventTypes.ACTIVITY_UPDATE_PRESENCE}`,
handler,
)
}
}, [roomName, identity, socketIsConnected])

Expand Down
11 changes: 1 addition & 10 deletions src/components/modules/activity/Presence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ const ReadPresenceTimeline = () => {
const { roomName } = useRoomContext()
const activityPresenceIdsCurrentRoom = useActivityPresenceByRoomName(roomName)

// console.log(activityPresenceIdsCurrentRoom, 'activityPresenceIdsCurrentRoom')
// console.log(

// activityPresence,
// 'activityPresence',
// sessionId,
// useActivityPresence(),
// )

return (
<RootPortal>
<div className="group fixed bottom-20 left-0 top-20 z-[3]">
Expand Down Expand Up @@ -181,7 +172,7 @@ const TimelineItem: FC<TimelineItemProps> = memo(({ type, identity }) => {

if (typeof position !== 'number') return null
const readingDuration = presence
? formatSeconds((presence.operationTime - presence.connectedAt) / 1000)
? formatSeconds((presence.operationTime - presence.joinedAt) / 1000)
: ''

return (
Expand Down
1 change: 1 addition & 0 deletions src/socket/socket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SocketClient {

this.socket.close()
this.socket.open()
setSocketIsConnect(this.socket.connected)
this.socket.on(
'message',
(payload: string | Record<'type' | 'data', any>) => {
Expand Down

0 comments on commit 6fe7f65

Please sign in to comment.