mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(accounts): adapt 5chan to compact account history hooks (#1118)
* chore(cursor): use composer-2 for subagents * fix(accounts): adapt 5chan to compact account history hooks * fix(accounts): address 5chan account-history review findings
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||
import { Comment, useAccount, useAccountComments } from '@bitsocialnet/bitsocial-react-hooks';
|
||||
import { Comment, useAccount } from '@bitsocialnet/bitsocial-react-hooks';
|
||||
import { useFloating, offset, shift, size, autoUpdate, Placement } from '@floating-ui/react';
|
||||
import { useDirectories } from '../../hooks/use-directories';
|
||||
import useSafeAccountComment from '../../hooks/use-safe-account-comment';
|
||||
import { getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { formatQuoteNumber, getQuoteTargetAvailability, shouldShowFloatingQuotePreview } from '../../lib/utils/quote-link-utils';
|
||||
import { findPreferredScrollTarget, getThreadTopNavigationState, scrollThreadContainerToTop } from '../../lib/utils/thread-scroll-utils';
|
||||
@@ -80,6 +81,17 @@ const scrollToReplyOnPage = (cid: string) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const useIsOwnQuotelink = (quotelinkReply?: Comment) => {
|
||||
const account = useAccount();
|
||||
const ownQuotelink = useSafeAccountComment({ commentCid: quotelinkReply?.cid });
|
||||
const quotedAuthorAddress = quotelinkReply?.author?.address;
|
||||
const accountAuthorAddress = account?.author?.address;
|
||||
|
||||
return Boolean(
|
||||
(quotelinkReply?.cid && ownQuotelink?.cid === quotelinkReply.cid) || (quotedAuthorAddress && accountAuthorAddress && quotedAuthorAddress === accountAuthorAddress),
|
||||
);
|
||||
};
|
||||
|
||||
const DesktopQuotePreview = ({
|
||||
backlinkReply,
|
||||
quotelinkReply,
|
||||
@@ -204,10 +216,6 @@ const DesktopQuotePreview = ({
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
const account = useAccount();
|
||||
const { accountComments } = useAccountComments();
|
||||
|
||||
const resolvedQuotelinkNumber = normalizedQuotelinkReply?.number ?? quotelinkNumber;
|
||||
const resolvedQuotelinkCid = normalizedQuotelinkReply?.cid;
|
||||
const resolvedQuotelinkCommunityAddress = getCommentCommunityAddress(normalizedQuotelinkReply);
|
||||
@@ -227,9 +235,7 @@ const DesktopQuotePreview = ({
|
||||
quoteCid: resolvedQuotelinkCid,
|
||||
isUnavailable: quotelinkUnavailable,
|
||||
});
|
||||
const isOwnQuotelink =
|
||||
(resolvedQuotelinkCid ? accountComments.some((comment) => comment.cid === resolvedQuotelinkCid) : false) ||
|
||||
normalizedQuotelinkReply?.author?.address === account?.author?.address;
|
||||
const isOwnQuotelink = useIsOwnQuotelink(normalizedQuotelinkReply);
|
||||
const quotelinkLabel = (
|
||||
<>
|
||||
{formatQuoteNumber(resolvedQuotelinkNumber)}
|
||||
@@ -374,9 +380,6 @@ const MobileQuotePreview = ({
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
const account = useAccount();
|
||||
const { accountComments } = useAccountComments();
|
||||
const resolvedQuotelinkNumber = normalizedQuotelinkReply?.number ?? quotelinkNumber;
|
||||
const resolvedQuotelinkCid = normalizedQuotelinkReply?.cid;
|
||||
const resolvedQuotelinkCommunityAddress = getCommentCommunityAddress(normalizedQuotelinkReply);
|
||||
@@ -390,9 +393,7 @@ const MobileQuotePreview = ({
|
||||
quoteCid: resolvedQuotelinkCid,
|
||||
isUnavailable: quotelinkUnavailable,
|
||||
});
|
||||
const isOwnQuotelink =
|
||||
(resolvedQuotelinkCid ? accountComments.some((comment) => comment.cid === resolvedQuotelinkCid) : false) ||
|
||||
normalizedQuotelinkReply?.author?.address === account?.author?.address;
|
||||
const isOwnQuotelink = useIsOwnQuotelink(normalizedQuotelinkReply);
|
||||
|
||||
const replyQuotelink = (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user