Skip to content

Commit

Permalink
fix: allow CommentsListItem to be compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 26, 2024
1 parent 349da36 commit 7938e58
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
} = props
const {t} = useTranslation(commentsLocaleNamespace)
const [value, setValue] = useState<CommentMessage>(EMPTY_ARRAY)
const [collapsed, setCollapsed] = useState<boolean>(true)
const didExpand = useRef<boolean>(false)
const [collapsed, setCollapsed] = useState(true)
const [didExpand, setDidExpand] = useState(false)
const replyInputRef = useRef<CommentInputHandle>(null)

const {isTopLayer} = useLayer()
Expand Down Expand Up @@ -238,7 +238,7 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
const handleExpand = useCallback((e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation()
setCollapsed(false)
didExpand.current = true
setDidExpand(true)
}, [])

const splicedReplies = useMemo(() => {
Expand All @@ -258,10 +258,10 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
}, [replies?.length])

useEffect(() => {
if (replies.length > MAX_COLLAPSED_REPLIES && !didExpand.current) {
if (replies.length > MAX_COLLAPSED_REPLIES && !didExpand) {
setCollapsed(true)
}
}, [replies])
}, [replies, didExpand])

const renderedReplies = useMemo(
() =>
Expand Down Expand Up @@ -356,7 +356,7 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
/>
</Stack>

{showCollapseButton && !didExpand.current && (
{showCollapseButton && !didExpand && (
<Flex gap={1} paddingY={1} sizing="border">
<SpacerAvatar />

Expand Down

0 comments on commit 7938e58

Please sign in to comment.