1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-11 21:29:17 +09:00

[Glitch] Add account notes to hover cards

Port 97b9e8befd to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Renaud Chaput 2024-08-06 08:53:59 +02:00 committed by Claire
parent ad786cb7af
commit 01b4c996b2
3 changed files with 38 additions and 1 deletions

View File

@ -1,5 +1,7 @@
import { useEffect, forwardRef } from 'react'; import { useEffect, forwardRef } from 'react';
import { FormattedMessage } from 'react-intl';
import classNames from 'classnames'; import classNames from 'classnames';
import { fetchAccount } from 'flavours/glitch/actions/accounts'; import { fetchAccount } from 'flavours/glitch/actions/accounts';
@ -25,6 +27,11 @@ export const HoverCardAccount = forwardRef<
accountId ? state.accounts.get(accountId) : undefined, accountId ? state.accounts.get(accountId) : undefined,
); );
const note = useAppSelector(
(state) =>
state.relationships.getIn([accountId, 'note']) as string | undefined,
);
useEffect(() => { useEffect(() => {
if (accountId && !account) { if (accountId && !account) {
dispatch(fetchAccount(accountId)); dispatch(fetchAccount(accountId));
@ -57,6 +64,17 @@ export const HoverCardAccount = forwardRef<
className='hover-card__bio' className='hover-card__bio'
/> />
<AccountFields fields={account.fields} limit={2} /> <AccountFields fields={account.fields} limit={2} />
{note && note.length > 0 && (
<dl className='hover-card__note'>
<dt className='hover-card__note-label'>
<FormattedMessage
id='account.account_note_header'
defaultMessage='Personal note'
/>
</dt>
<dd>{note}</dd>
</dl>
)}
</div> </div>
<div className='hover-card__number'> <div className='hover-card__number'>

View File

@ -151,7 +151,7 @@ class AccountNote extends ImmutablePureComponent {
return ( return (
<div className='account__header__account-note'> <div className='account__header__account-note'>
<label htmlFor={`account-note-${account.get('id')}`}> <label htmlFor={`account-note-${account.get('id')}`}>
<FormattedMessage id='account.account_note_header' defaultMessage='Note' /> <InlineAlert show={saved} /> <FormattedMessage id='account.account_note_header' defaultMessage='Personal note' /> <InlineAlert show={saved} />
</label> </label>
<Textarea <Textarea

View File

@ -11177,6 +11177,25 @@ noscript {
} }
} }
&__note {
&-label {
color: $dark-text-color;
font-size: 12px;
font-weight: 500;
text-transform: uppercase;
}
dd {
white-space: pre-line;
color: $secondary-text-color;
overflow: hidden;
line-clamp: 3; // Not yet supported in browers
display: -webkit-box; // The next 3 properties are needed
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
}
.display-name { .display-name {
font-size: 15px; font-size: 15px;
line-height: 22px; line-height: 22px;