Refactor: Replace all display name usage for new component (#36137)
This commit is contained in:
24 files changed
+198
-364
No files matched your search
@@ -1,22 +0,0 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { useAppSelector } from 'mastodon/store';
|
||||
|
||||
export const DisplayedName: React.FC<{
|
||||
accountIds: string[];
|
||||
}> = ({ accountIds }) => {
|
||||
const lastAccountId = accountIds[0] ?? '0';
|
||||
const account = useAppSelector((state) => state.accounts.get(lastAccountId));
|
||||
|
||||
if (!account) return null;
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={`/@${account.acct}`}
|
||||
title={`@${account.acct}`}
|
||||
data-hover-card-account={account.id}
|
||||
>
|
||||
<bdi dangerouslySetInnerHTML={{ __html: account.display_name_html }} />
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
+3
-4
@@ -2,6 +2,7 @@ import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { DisplayName } from '@/mastodon/components/display_name';
|
||||
import FlagIcon from '@/material-icons/400-24px/flag-fill.svg?react';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
|
||||
@@ -42,11 +43,9 @@ export const NotificationAdminReport: React.FC<{
|
||||
|
||||
if (!account || !targetAccount) return null;
|
||||
|
||||
const domain = account.acct.split('@')[1];
|
||||
|
||||
const values = {
|
||||
name: <bdi>{domain ?? `@${account.acct}`}</bdi>,
|
||||
target: <bdi>@{targetAccount.acct}</bdi>,
|
||||
name: <DisplayName account={account} variant='simple' />,
|
||||
target: <DisplayName account={targetAccount} variant='simple' />,
|
||||
category: intl.formatMessage(messages[report.category]),
|
||||
count: report.status_ids.length,
|
||||
};
|
||||
|
||||
+6
-3
@@ -3,6 +3,7 @@ import type { JSX } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { LinkedDisplayName } from '@/mastodon/components/display_name';
|
||||
import { replyComposeById } from 'mastodon/actions/compose';
|
||||
import { navigateToStatus } from 'mastodon/actions/statuses';
|
||||
import { Avatar } from 'mastodon/components/avatar';
|
||||
@@ -14,7 +15,6 @@ import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
|
||||
import { NOTIFICATIONS_GROUP_MAX_AVATARS } from 'mastodon/models/notification_group';
|
||||
import { useAppSelector, useAppDispatch } from 'mastodon/store';
|
||||
|
||||
import { DisplayedName } from './displayed_name';
|
||||
import { EmbeddedStatus } from './embedded_status';
|
||||
|
||||
const AVATAR_SIZE = 28;
|
||||
@@ -61,15 +61,18 @@ export const NotificationGroupWithStatus: React.FC<{
|
||||
additionalContent,
|
||||
}) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const account = useAppSelector((state) =>
|
||||
state.accounts.get(accountIds.at(0) ?? ''),
|
||||
);
|
||||
|
||||
const label = useMemo(
|
||||
() =>
|
||||
labelRenderer(
|
||||
<DisplayedName accountIds={accountIds} />,
|
||||
<LinkedDisplayName displayProps={{ account, variant: 'simple' }} />,
|
||||
count,
|
||||
labelSeeMoreHref,
|
||||
),
|
||||
[labelRenderer, accountIds, count, labelSeeMoreHref],
|
||||
[labelRenderer, account, count, labelSeeMoreHref],
|
||||
);
|
||||
|
||||
const isPrivateMention = useAppSelector(
|
||||
|
||||
+10
-3
@@ -2,6 +2,7 @@ import { useMemo } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { LinkedDisplayName } from '@/mastodon/components/display_name';
|
||||
import { replyComposeById } from 'mastodon/actions/compose';
|
||||
import { toggleReblog, toggleFavourite } from 'mastodon/actions/interactions';
|
||||
import {
|
||||
@@ -15,7 +16,6 @@ import { StatusQuoteManager } from 'mastodon/components/status_quoted';
|
||||
import { getStatusHidden } from 'mastodon/selectors/filters';
|
||||
import { useAppSelector, useAppDispatch } from 'mastodon/store';
|
||||
|
||||
import { DisplayedName } from './displayed_name';
|
||||
import type { LabelRenderer } from './notification_group_with_status';
|
||||
|
||||
export const NotificationWithStatus: React.FC<{
|
||||
@@ -39,9 +39,16 @@ export const NotificationWithStatus: React.FC<{
|
||||
}) => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const account = useAppSelector((state) =>
|
||||
state.accounts.get(accountIds.at(0) ?? ''),
|
||||
);
|
||||
const label = useMemo(
|
||||
() => labelRenderer(<DisplayedName accountIds={accountIds} />, count),
|
||||
[labelRenderer, accountIds, count],
|
||||
() =>
|
||||
labelRenderer(
|
||||
<LinkedDisplayName displayProps={{ account, variant: 'simple' }} />,
|
||||
count,
|
||||
),
|
||||
[labelRenderer, account, count],
|
||||
);
|
||||
|
||||
const isPrivateMention = useAppSelector(
|
||||
|
||||
Reference in new issue
Block a user