diff --git a/src/components/reply-quote-preview/__tests__/reply-quote-preview.test.tsx b/src/components/reply-quote-preview/__tests__/reply-quote-preview.test.tsx index e2fd5b0d..ad7420e2 100644 --- a/src/components/reply-quote-preview/__tests__/reply-quote-preview.test.tsx +++ b/src/components/reply-quote-preview/__tests__/reply-quote-preview.test.tsx @@ -23,6 +23,7 @@ const testState = vi.hoisted(() => ({ address: '0xme', }, }, + accountComments: [] as Array<{ cid?: string }>, directories: [{ address: 'music-posting.eth', title: '/mu/ - Music' }] as Array<{ address: string; title?: string }>, isMobile: false, locationPath: '/mu/thread/thread-cid', @@ -58,6 +59,7 @@ vi.mock('react-router-dom', async () => { vi.mock('@bitsocialnet/bitsocial-react-hooks', () => ({ useAccount: () => testState.account, + useAccountComments: () => ({ accountComments: testState.accountComments }), })); vi.mock('@floating-ui/react', () => ({ @@ -173,6 +175,7 @@ describe('ReplyQuotePreview', () => { address: '0xme', }, }; + testState.accountComments = []; testState.directories = [{ address: 'music-posting.eth', title: '/mu/ - Music' }]; testState.isMobile = false; testState.locationPath = '/mu/thread/thread-cid'; diff --git a/src/components/reply-quote-preview/reply-quote-preview.tsx b/src/components/reply-quote-preview/reply-quote-preview.tsx index cb9d376b..b33afcea 100644 --- a/src/components/reply-quote-preview/reply-quote-preview.tsx +++ b/src/components/reply-quote-preview/reply-quote-preview.tsx @@ -1,7 +1,7 @@ import { useEffect, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { Link, useLocation, useNavigate } from 'react-router-dom'; -import { Comment, useAccount } from '@bitsocialnet/bitsocial-react-hooks'; +import { Comment, useAccount, useAccountComments } from '@bitsocialnet/bitsocial-react-hooks'; import { useFloating, offset, shift, size, autoUpdate, Placement } from '@floating-ui/react'; import { useDirectories } from '../../hooks/use-directories'; import { getBoardPath } from '../../lib/utils/route-utils'; @@ -206,6 +206,7 @@ const DesktopQuotePreview = ({ ); const account = useAccount(); + const { accountComments } = useAccountComments(); const resolvedQuotelinkNumber = normalizedQuotelinkReply?.number ?? quotelinkNumber; const resolvedQuotelinkCid = normalizedQuotelinkReply?.cid; @@ -226,11 +227,14 @@ const DesktopQuotePreview = ({ quoteCid: resolvedQuotelinkCid, isUnavailable: quotelinkUnavailable, }); + const isOwnQuotelink = + (resolvedQuotelinkCid ? accountComments.some((comment) => comment.cid === resolvedQuotelinkCid) : false) || + normalizedQuotelinkReply?.author?.address === account?.author?.address; const quotelinkLabel = ( <> {formatQuoteNumber(resolvedQuotelinkNumber)} {isOP && ' (OP)'} - {normalizedQuotelinkReply?.author?.address === account?.author?.address && ' (You)'} + {isOwnQuotelink && ' (You)'} ); @@ -372,6 +376,7 @@ const MobileQuotePreview = ({ ); const account = useAccount(); + const { accountComments } = useAccountComments(); const resolvedQuotelinkNumber = normalizedQuotelinkReply?.number ?? quotelinkNumber; const resolvedQuotelinkCid = normalizedQuotelinkReply?.cid; const resolvedQuotelinkCommunityAddress = getCommentCommunityAddress(normalizedQuotelinkReply); @@ -385,6 +390,9 @@ const MobileQuotePreview = ({ quoteCid: resolvedQuotelinkCid, isUnavailable: quotelinkUnavailable, }); + const isOwnQuotelink = + (resolvedQuotelinkCid ? accountComments.some((comment) => comment.cid === resolvedQuotelinkCid) : false) || + normalizedQuotelinkReply?.author?.address === account?.author?.address; const replyQuotelink = ( <> @@ -396,7 +404,7 @@ const MobileQuotePreview = ({ > {formatQuoteNumber(resolvedQuotelinkNumber)} {isOP && ' (OP)'} - {normalizedQuotelinkReply?.author?.address === account?.author?.address && ' (You)'} + {isOwnQuotelink && ' (You)'} {!quotelinkUnavailable && !quotelinkPendingResolution &&