mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-08 10:50:58 +00:00
fix: Show hint for quotes hidden by filter (#34790)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
This commit is contained in:
parent
304c0417ed
commit
a13756148d
|
@ -1,3 +1,5 @@
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
@ -10,9 +12,11 @@ import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react'
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import StatusContainer from 'mastodon/containers/status_container';
|
import StatusContainer from 'mastodon/containers/status_container';
|
||||||
import type { Status } from 'mastodon/models/status';
|
import type { Status } from 'mastodon/models/status';
|
||||||
|
import type { RootState } from 'mastodon/store';
|
||||||
import { useAppSelector } from 'mastodon/store';
|
import { useAppSelector } from 'mastodon/store';
|
||||||
|
|
||||||
import QuoteIcon from '../../images/quote.svg?react';
|
import QuoteIcon from '../../images/quote.svg?react';
|
||||||
|
import { makeGetStatus } from '../selectors';
|
||||||
|
|
||||||
const MAX_QUOTE_POSTS_NESTING_LEVEL = 1;
|
const MAX_QUOTE_POSTS_NESTING_LEVEL = 1;
|
||||||
|
|
||||||
|
@ -65,6 +69,10 @@ const QuoteLink: React.FC<{
|
||||||
};
|
};
|
||||||
|
|
||||||
type QuoteMap = ImmutableMap<'state' | 'quoted_status', string | null>;
|
type QuoteMap = ImmutableMap<'state' | 'quoted_status', string | null>;
|
||||||
|
type GetStatusSelector = (
|
||||||
|
state: RootState,
|
||||||
|
props: { id?: string | null; contextType?: string },
|
||||||
|
) => Status | null;
|
||||||
|
|
||||||
export const QuotedStatus: React.FC<{
|
export const QuotedStatus: React.FC<{
|
||||||
quote: QuoteMap;
|
quote: QuoteMap;
|
||||||
|
@ -73,34 +81,50 @@ export const QuotedStatus: React.FC<{
|
||||||
nestingLevel?: number;
|
nestingLevel?: number;
|
||||||
}> = ({ quote, contextType, nestingLevel = 1, variant = 'full' }) => {
|
}> = ({ quote, contextType, nestingLevel = 1, variant = 'full' }) => {
|
||||||
const quotedStatusId = quote.get('quoted_status');
|
const quotedStatusId = quote.get('quoted_status');
|
||||||
const state = quote.get('state');
|
const quoteState = quote.get('state');
|
||||||
const status = useAppSelector((state) =>
|
const status = useAppSelector((state) =>
|
||||||
quotedStatusId ? state.statuses.get(quotedStatusId) : undefined,
|
quotedStatusId ? state.statuses.get(quotedStatusId) : undefined,
|
||||||
);
|
);
|
||||||
let quoteError: React.ReactNode = null;
|
let quoteError: React.ReactNode = null;
|
||||||
|
|
||||||
if (state === 'deleted') {
|
// In order to find out whether the quoted post should be completely hidden
|
||||||
|
// due to a matching filter, we run it through the selector used by `status_container`.
|
||||||
|
// If this returns null even though `status` exists, it's because it's filtered.
|
||||||
|
const getStatus = useMemo(() => makeGetStatus(), []) as GetStatusSelector;
|
||||||
|
const statusWithExtraData = useAppSelector((state) =>
|
||||||
|
getStatus(state, { id: quotedStatusId, contextType }),
|
||||||
|
);
|
||||||
|
const isFilteredAndHidden = status && statusWithExtraData === null;
|
||||||
|
|
||||||
|
if (isFilteredAndHidden) {
|
||||||
|
quoteError = (
|
||||||
|
<FormattedMessage
|
||||||
|
id='status.quote_error.filtered'
|
||||||
|
defaultMessage='Hidden due to one of your filters'
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if (quoteState === 'deleted') {
|
||||||
quoteError = (
|
quoteError = (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='status.quote_error.removed'
|
id='status.quote_error.removed'
|
||||||
defaultMessage='This post was removed by its author.'
|
defaultMessage='This post was removed by its author.'
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (state === 'unauthorized') {
|
} else if (quoteState === 'unauthorized') {
|
||||||
quoteError = (
|
quoteError = (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='status.quote_error.unauthorized'
|
id='status.quote_error.unauthorized'
|
||||||
defaultMessage='This post cannot be displayed as you are not authorized to view it.'
|
defaultMessage='This post cannot be displayed as you are not authorized to view it.'
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (state === 'pending') {
|
} else if (quoteState === 'pending') {
|
||||||
quoteError = (
|
quoteError = (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='status.quote_error.pending_approval'
|
id='status.quote_error.pending_approval'
|
||||||
defaultMessage='This post is pending approval from the original author.'
|
defaultMessage='This post is pending approval from the original author.'
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (state === 'rejected' || state === 'revoked') {
|
} else if (quoteState === 'rejected' || quoteState === 'revoked') {
|
||||||
quoteError = (
|
quoteError = (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='status.quote_error.rejected'
|
id='status.quote_error.rejected'
|
||||||
|
|
|
@ -864,6 +864,7 @@
|
||||||
"status.mute_conversation": "Mute conversation",
|
"status.mute_conversation": "Mute conversation",
|
||||||
"status.open": "Expand this post",
|
"status.open": "Expand this post",
|
||||||
"status.pin": "Feature on profile",
|
"status.pin": "Feature on profile",
|
||||||
|
"status.quote_error.filtered": "Hidden due to one of your filters",
|
||||||
"status.quote_error.not_found": "This post cannot be displayed.",
|
"status.quote_error.not_found": "This post cannot be displayed.",
|
||||||
"status.quote_error.pending_approval": "This post is pending approval from the original author.",
|
"status.quote_error.pending_approval": "This post is pending approval from the original author.",
|
||||||
"status.quote_error.rejected": "This post cannot be displayed as the original author does not allow it to be quoted.",
|
"status.quote_error.rejected": "This post cannot be displayed as the original author does not allow it to be quoted.",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user