fix(comment-content): ensure parent comment number is populated for nested replies

This commit is contained in:
plebeius
2026-01-19 14:34:26 +01:00
parent 5e1114e087
commit c2bbe2dd0b
@@ -1,7 +1,7 @@
import { Fragment, useState } from 'react'; import { Fragment, useState } from 'react';
import { useLocation, useParams } from 'react-router-dom'; import { useLocation, useParams } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
import { Comment } from '@plebbit/plebbit-react-hooks'; import { Comment, useComment } from '@plebbit/plebbit-react-hooks';
import useSubplebbitsPagesStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits-pages'; import useSubplebbitsPagesStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits-pages';
import Plebbit from '@plebbit/plebbit-js'; import Plebbit from '@plebbit/plebbit-js';
import { getFormattedDate, getFormattedTimeAgo } from '../../lib/utils/time-utils'; import { getFormattedDate, getFormattedTimeAgo } from '../../lib/utils/time-utils';
@@ -35,7 +35,10 @@ const CommentContent = ({ comment: post }: { comment: Comment }) => {
? content.slice(0, 2000) ? content.slice(0, 2000)
: content); : content);
const quotelinkReply = useSubplebbitsPagesStore((state) => state.comments[parentCid]); const quotelinkReplyFromStore = useSubplebbitsPagesStore((state) => state.comments[parentCid]);
const quotelinkReplyFromHook = useComment({ commentCid: parentCid, onlyIfCached: true });
// Prefer hook version to ensure 'number' property is populated for deeper nested replies in Virtuoso
const quotelinkReply = quotelinkReplyFromHook?.number !== undefined ? quotelinkReplyFromHook : quotelinkReplyFromStore;
const isReply = !!parentCid; const isReply = !!parentCid;
const isReplyingToReply = isReply && parentCid !== postCid; const isReplyingToReply = isReply && parentCid !== postCid;