From 97b9e8befd7355af7a2a2905a16f5f0527f0b48c Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Tue, 6 Aug 2024 08:53:59 +0200 Subject: [PATCH] Add account notes to hover cards (#31300) --- .../components/hover_card_account.tsx | 18 ++++++++++++++++++ .../account/components/account_note.jsx | 2 +- app/javascript/mastodon/locales/en.json | 2 +- .../styles/mastodon/components.scss | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/components/hover_card_account.tsx b/app/javascript/mastodon/components/hover_card_account.tsx index 8933e14a98..05033e4ac7 100644 --- a/app/javascript/mastodon/components/hover_card_account.tsx +++ b/app/javascript/mastodon/components/hover_card_account.tsx @@ -1,5 +1,7 @@ import { useEffect, forwardRef } from 'react'; +import { FormattedMessage } from 'react-intl'; + import classNames from 'classnames'; import { Link } from 'react-router-dom'; @@ -25,6 +27,11 @@ export const HoverCardAccount = forwardRef< accountId ? state.accounts.get(accountId) : undefined, ); + const note = useAppSelector( + (state) => + state.relationships.getIn([accountId, 'note']) as string | undefined, + ); + useEffect(() => { if (accountId && !account) { dispatch(fetchAccount(accountId)); @@ -53,6 +60,17 @@ export const HoverCardAccount = forwardRef< className='hover-card__bio' /> + {note && note.length > 0 && ( +
+
+ +
+
{note}
+
+ )}
diff --git a/app/javascript/mastodon/features/account/components/account_note.jsx b/app/javascript/mastodon/features/account/components/account_note.jsx index 272a4ee312..e736e7ad64 100644 --- a/app/javascript/mastodon/features/account/components/account_note.jsx +++ b/app/javascript/mastodon/features/account/components/account_note.jsx @@ -151,7 +151,7 @@ class AccountNote extends ImmutablePureComponent { return (