Skip to content

Commit

Permalink
Only observe parent comment visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Apr 24, 2023
1 parent d07c28d commit 4deae56
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions web/components/feed/feed-comments.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, ReactNode, useEffect, useState } from 'react'
import React, { memo, ReactNode, useEffect, useRef, useState } from 'react'
import { Editor } from '@tiptap/react'
import clsx from 'clsx'

Expand Down Expand Up @@ -65,9 +65,16 @@ export function FeedCommentThread(props: {
const [collapseToIndex, setCollapseToIndex] = useState<number>(
collapseMiddle && threadComments.length > 2 ? threadComments.length - 2 : -1
)

const { ref } = useIsVisible(
() =>
track('view comment thread', {
contractId: contract.id,
commentId: parentComment.id,
} as CommentView),
true
)
return (
<Col className="w-full items-stretch gap-3 pb-2">
<Col className="w-full items-stretch gap-3 pb-2" ref={ref}>
<ParentFeedComment
key={parentComment.id}
contract={contract}
Expand Down Expand Up @@ -142,14 +149,7 @@ export const FeedComment = memo(function FeedComment(props: {
children,
} = props
const { userUsername, userAvatarUrl, bettorUsername } = comment
const { ref } = useIsVisible(
() =>
track('view comment', {
contractId: contract.id,
commentId: comment.id,
} as CommentView),
true
)
const ref = useRef<HTMLDivElement>(null)
const marketCreator = contract.creatorId === comment.userId
const commentOnAnotherBettorsBet = bettorUsername !== undefined
useEffect(() => {
Expand Down

0 comments on commit 4deae56

Please sign in to comment.