mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-06 09:02:43 +00:00
Add click-through for quoted limited accounts (#36167)
This commit is contained in:
parent
c368a16dc1
commit
16a6e5c118
|
@ -1,4 +1,4 @@
|
||||||
import { useEffect, useMemo, useRef } from 'react';
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
@ -6,13 +6,16 @@ import type { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
import { LearnMoreLink } from 'mastodon/components/learn_more_link';
|
import { LearnMoreLink } from 'mastodon/components/learn_more_link';
|
||||||
import StatusContainer from 'mastodon/containers/status_container';
|
import StatusContainer from 'mastodon/containers/status_container';
|
||||||
|
import { domain } from 'mastodon/initial_state';
|
||||||
|
import type { Account } from 'mastodon/models/account';
|
||||||
import type { Status } from 'mastodon/models/status';
|
import type { Status } from 'mastodon/models/status';
|
||||||
import type { RootState } from 'mastodon/store';
|
import type { RootState } from 'mastodon/store';
|
||||||
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||||
|
|
||||||
|
import { revealAccount } from '../actions/accounts_typed';
|
||||||
import { fetchStatus } from '../actions/statuses';
|
import { fetchStatus } from '../actions/statuses';
|
||||||
import type { Account } from '../models/account';
|
|
||||||
import { makeGetStatusWithExtraInfo } from '../selectors';
|
import { makeGetStatusWithExtraInfo } from '../selectors';
|
||||||
|
import { getAccountHidden } from '../selectors/accounts';
|
||||||
|
|
||||||
import { Button } from './button';
|
import { Button } from './button';
|
||||||
|
|
||||||
|
@ -56,6 +59,29 @@ type GetStatusSelector = (
|
||||||
|
|
||||||
type QuoteMap = ImmutableMap<'state' | 'quoted_status', string | null>;
|
type QuoteMap = ImmutableMap<'state' | 'quoted_status', string | null>;
|
||||||
|
|
||||||
|
const LimitedAccountHint: React.FC<{ accountId: string }> = ({ accountId }) => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const reveal = useCallback(() => {
|
||||||
|
dispatch(revealAccount({ id: accountId }));
|
||||||
|
}, [dispatch, accountId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FormattedMessage
|
||||||
|
id='status.quote_error.limited_account_hint.title'
|
||||||
|
defaultMessage='This account has been hidden by the moderators of {domain}.'
|
||||||
|
values={{ domain }}
|
||||||
|
/>
|
||||||
|
<button onClick={reveal} className='link-button'>
|
||||||
|
<FormattedMessage
|
||||||
|
id='status.quote_error.limited_account_hint.action'
|
||||||
|
defaultMessage='Show anyway'
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
interface QuotedStatusProps {
|
interface QuotedStatusProps {
|
||||||
quote: QuoteMap;
|
quote: QuoteMap;
|
||||||
contextType?: string;
|
contextType?: string;
|
||||||
|
@ -89,6 +115,13 @@ export const QuotedStatus: React.FC<QuotedStatusProps> = ({
|
||||||
getStatusSelector(state, { id: quotedStatusId, contextType }),
|
getStatusSelector(state, { id: quotedStatusId, contextType }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const accountId: string | null = status?.get('account')
|
||||||
|
? (status.get('account') as Account).id
|
||||||
|
: null;
|
||||||
|
const hiddenAccount = useAppSelector(
|
||||||
|
(state) => accountId && getAccountHidden(state, accountId),
|
||||||
|
);
|
||||||
|
|
||||||
const shouldFetchQuote =
|
const shouldFetchQuote =
|
||||||
!status?.get('isLoading') &&
|
!status?.get('isLoading') &&
|
||||||
quoteState !== 'deleted' &&
|
quoteState !== 'deleted' &&
|
||||||
|
@ -164,6 +197,8 @@ export const QuotedStatus: React.FC<QuotedStatusProps> = ({
|
||||||
defaultMessage='Post unavailable'
|
defaultMessage='Post unavailable'
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
} else if (hiddenAccount && accountId) {
|
||||||
|
quoteError = <LimitedAccountHint accountId={accountId} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quoteError) {
|
if (quoteError) {
|
||||||
|
|
|
@ -895,6 +895,8 @@
|
||||||
"status.quote": "Quote",
|
"status.quote": "Quote",
|
||||||
"status.quote.cancel": "Cancel quote",
|
"status.quote.cancel": "Cancel quote",
|
||||||
"status.quote_error.filtered": "Hidden due to one of your filters",
|
"status.quote_error.filtered": "Hidden due to one of your filters",
|
||||||
|
"status.quote_error.limited_account_hint.action": "Show anyway",
|
||||||
|
"status.quote_error.limited_account_hint.title": "This account has been hidden by the moderators of {domain}.",
|
||||||
"status.quote_error.not_available": "Post unavailable",
|
"status.quote_error.not_available": "Post unavailable",
|
||||||
"status.quote_error.pending_approval": "Post pending",
|
"status.quote_error.pending_approval": "Post pending",
|
||||||
"status.quote_error.pending_approval_popout.body": "On Mastodon, you can control whether someone can quote you. This post is pending while we're getting the original author's approval.",
|
"status.quote_error.pending_approval_popout.body": "On Mastodon, you can control whether someone can quote you. This post is pending while we're getting the original author's approval.",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user