From 58016b9c332a92fd6e6ce8834d21f78df2127d2b Mon Sep 17 00:00:00 2001 From: diondiondion Date: Mon, 15 Sep 2025 11:21:03 +0200 Subject: [PATCH] [Glitch] In composer, show when quoted post is also a quote post Port 681a9cfda12ddc2248723ec474f0d1218b7061fb to glitch-soc Signed-off-by: Claire --- .../glitch/components/status_quoted.tsx | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status_quoted.tsx b/app/javascript/flavours/glitch/components/status_quoted.tsx index d582e043c3..2788cf58af 100644 --- a/app/javascript/flavours/glitch/components/status_quoted.tsx +++ b/app/javascript/flavours/glitch/components/status_quoted.tsx @@ -2,8 +2,6 @@ import { useEffect, useMemo, useRef } from 'react'; import { FormattedMessage } from 'react-intl'; -import classNames from 'classnames'; - import type { Map as ImmutableMap } from 'immutable'; import { LearnMoreLink } from 'flavours/glitch/components/learn_more_link'; @@ -13,36 +11,20 @@ import type { RootState } from 'flavours/glitch/store'; import { useAppDispatch, useAppSelector } from 'flavours/glitch/store'; import { fetchStatus } from '../actions/statuses'; +import type { Account } from '../models/account'; import { makeGetStatusWithExtraInfo } from '../selectors'; import { Button } from './button'; const MAX_QUOTE_POSTS_NESTING_LEVEL = 1; -const QuoteWrapper: React.FC<{ - isError?: boolean; - contextType?: string; - onQuoteCancel?: () => void; - children: React.ReactElement; -}> = ({ isError, contextType, onQuoteCancel, children }) => { - return ( -
- {children} - {contextType === 'composer' && ( - - )} -
- ); -}; - const NestedQuoteLink: React.FC<{ status: Status }> = ({ status }) => { - const accountId = status.get('account') as string; + const accountObjectOrId = status.get('account') as string | Account; + const accountId = + typeof accountObjectOrId === 'string' + ? accountObjectOrId + : accountObjectOrId.id; + const account = useAppSelector((state) => accountId ? state.accounts.get(accountId) : undefined, ); @@ -185,14 +167,20 @@ export const QuotedStatus: React.FC = ({ } if (quoteError) { + const hasRemoveButton = contextType === 'composer' && !!onQuoteCancel; + return ( - +
{quoteError} - + {hasRemoveButton && ( + + )} +
); } @@ -205,7 +193,7 @@ export const QuotedStatus: React.FC = ({ childQuote && nestingLevel <= MAX_QUOTE_POSTS_NESTING_LEVEL; return ( - +
{/* @ts-expect-error Status is not yet typed */} = ({ /> )} - +
); };