Fix filters not applying in detailed view (#34259)
This commit is contained in:
parent
ff2ba559e8
commit
853b848109
4 changed files with 34 additions and 12 deletions
|
@ -15,6 +15,7 @@ import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?re
|
||||||
import { AnimatedNumber } from 'mastodon/components/animated_number';
|
import { AnimatedNumber } from 'mastodon/components/animated_number';
|
||||||
import { ContentWarning } from 'mastodon/components/content_warning';
|
import { ContentWarning } from 'mastodon/components/content_warning';
|
||||||
import EditedTimestamp from 'mastodon/components/edited_timestamp';
|
import EditedTimestamp from 'mastodon/components/edited_timestamp';
|
||||||
|
import { FilterWarning } from 'mastodon/components/filter_warning';
|
||||||
import type { StatusLike } from 'mastodon/components/hashtag_bar';
|
import type { StatusLike } from 'mastodon/components/hashtag_bar';
|
||||||
import { getHashtagBarForStatus } from 'mastodon/components/hashtag_bar';
|
import { getHashtagBarForStatus } from 'mastodon/components/hashtag_bar';
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
|
@ -80,6 +81,7 @@ export const DetailedStatus: React.FC<{
|
||||||
}) => {
|
}) => {
|
||||||
const properStatus = status?.get('reblog') ?? status;
|
const properStatus = status?.get('reblog') ?? status;
|
||||||
const [height, setHeight] = useState(0);
|
const [height, setHeight] = useState(0);
|
||||||
|
const [showDespiteFilter, setShowDespiteFilter] = useState(false);
|
||||||
const nodeRef = useRef<HTMLDivElement>();
|
const nodeRef = useRef<HTMLDivElement>();
|
||||||
|
|
||||||
const handleOpenVideo = useCallback(
|
const handleOpenVideo = useCallback(
|
||||||
|
@ -92,6 +94,10 @@ export const DetailedStatus: React.FC<{
|
||||||
[onOpenVideo, status],
|
[onOpenVideo, status],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleFilterToggle = useCallback(() => {
|
||||||
|
setShowDespiteFilter(!showDespiteFilter);
|
||||||
|
}, [showDespiteFilter, setShowDespiteFilter]);
|
||||||
|
|
||||||
const handleExpandedToggle = useCallback(() => {
|
const handleExpandedToggle = useCallback(() => {
|
||||||
if (onToggleHidden) onToggleHidden(status);
|
if (onToggleHidden) onToggleHidden(status);
|
||||||
}, [onToggleHidden, status]);
|
}, [onToggleHidden, status]);
|
||||||
|
@ -369,8 +375,12 @@ export const DetailedStatus: React.FC<{
|
||||||
const { statusContentProps, hashtagBar } = getHashtagBarForStatus(
|
const { statusContentProps, hashtagBar } = getHashtagBarForStatus(
|
||||||
status as StatusLike,
|
status as StatusLike,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const matchedFilters = status.get('matched_filters');
|
||||||
|
|
||||||
const expanded =
|
const expanded =
|
||||||
!status.get('hidden') || status.get('spoiler_text').length === 0;
|
(!matchedFilters || showDespiteFilter) &&
|
||||||
|
(!status.get('hidden') || status.get('spoiler_text').length === 0);
|
||||||
|
|
||||||
const quote = !muted && status.get('quote_id') && (
|
const quote = !muted && status.get('quote_id') && (
|
||||||
<>
|
<>
|
||||||
|
@ -418,7 +428,16 @@ export const DetailedStatus: React.FC<{
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{status.get('spoiler_text').length > 0 && (
|
{matchedFilters && (
|
||||||
|
<FilterWarning
|
||||||
|
title={matchedFilters.join(', ')}
|
||||||
|
expanded={showDespiteFilter}
|
||||||
|
onClick={handleFilterToggle}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{status.get('spoiler_text').length > 0 &&
|
||||||
|
(!matchedFilters || showDespiteFilter) && (
|
||||||
<ContentWarning
|
<ContentWarning
|
||||||
text={
|
text={
|
||||||
status.getIn(['translation', 'spoilerHtml']) ||
|
status.getIn(['translation', 'spoilerHtml']) ||
|
||||||
|
|
|
@ -147,7 +147,7 @@ const makeMapStateToProps = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const status = getStatus(state, { id: props.params.statusId });
|
const status = getStatus(state, { id: props.params.statusId, contextType: 'detailed' });
|
||||||
|
|
||||||
let ancestorsIds = ImmutableList();
|
let ancestorsIds = ImmutableList();
|
||||||
let descendantsIds = ImmutableList();
|
let descendantsIds = ImmutableList();
|
||||||
|
|
|
@ -17,9 +17,10 @@ export const makeGetStatus = () => {
|
||||||
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', id, 'account'])]),
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', id, 'account'])]),
|
||||||
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'reblog']), 'account'])]),
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'reblog']), 'account'])]),
|
||||||
getFilters,
|
getFilters,
|
||||||
|
(_, { contextType }) => contextType === 'detailed',
|
||||||
],
|
],
|
||||||
|
|
||||||
(statusBase, statusReblog, statusQuote, statusReblogQuote, accountBase, accountReblog, filters) => {
|
(statusBase, statusReblog, statusQuote, statusReblogQuote, accountBase, accountReblog, filters, warnInsteadOfHide) => {
|
||||||
if (!statusBase || statusBase.get('isLoading')) {
|
if (!statusBase || statusBase.get('isLoading')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ export const makeGetStatus = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'hide')) {
|
if (!warnInsteadOfHide && filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'hide')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
filterResults = filterResults.filter(result => filters.has(result.get('filter')));
|
filterResults = filterResults.filter(result => filters.has(result.get('filter')));
|
||||||
|
|
|
@ -7,6 +7,8 @@ export const toServerSideType = (columnType: string) => {
|
||||||
case 'account':
|
case 'account':
|
||||||
case 'explore':
|
case 'explore':
|
||||||
return columnType;
|
return columnType;
|
||||||
|
case 'detailed':
|
||||||
|
return 'thread';
|
||||||
default:
|
default:
|
||||||
if (columnType.includes('list:') || columnType.includes('antenna:')) {
|
if (columnType.includes('list:') || columnType.includes('antenna:')) {
|
||||||
return 'home';
|
return 'home';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue