mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 08:19:05 +00:00
[Glitch] Fix filters not applying in detailed view
Port 8c3eeb4d29 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import { Link } from 'react-router-dom';
|
|||||||
import { AnimatedNumber } from 'flavours/glitch/components/animated_number';
|
import { AnimatedNumber } from 'flavours/glitch/components/animated_number';
|
||||||
import AttachmentList from 'flavours/glitch/components/attachment_list';
|
import AttachmentList from 'flavours/glitch/components/attachment_list';
|
||||||
import EditedTimestamp from 'flavours/glitch/components/edited_timestamp';
|
import EditedTimestamp from 'flavours/glitch/components/edited_timestamp';
|
||||||
|
import { FilterWarning } from 'flavours/glitch/components/filter_warning';
|
||||||
import type { StatusLike } from 'flavours/glitch/components/hashtag_bar';
|
import type { StatusLike } from 'flavours/glitch/components/hashtag_bar';
|
||||||
import { getHashtagBarForStatus } from 'flavours/glitch/components/hashtag_bar';
|
import { getHashtagBarForStatus } from 'flavours/glitch/components/hashtag_bar';
|
||||||
import { IconLogo } from 'flavours/glitch/components/logo';
|
import { IconLogo } from 'flavours/glitch/components/logo';
|
||||||
@@ -72,6 +73,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 history = useAppHistory();
|
const history = useAppHistory();
|
||||||
|
|
||||||
@@ -108,6 +110,10 @@ export const DetailedStatus: React.FC<{
|
|||||||
[onOpenVideo, status],
|
[onOpenVideo, status],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleFilterToggle = useCallback(() => {
|
||||||
|
setShowDespiteFilter(!showDespiteFilter);
|
||||||
|
}, [showDespiteFilter, setShowDespiteFilter]);
|
||||||
|
|
||||||
const _measureHeight = useCallback(
|
const _measureHeight = useCallback(
|
||||||
(heightJustChanged?: boolean) => {
|
(heightJustChanged?: boolean) => {
|
||||||
if (measureHeight && nodeRef.current) {
|
if (measureHeight && nodeRef.current) {
|
||||||
@@ -358,6 +364,8 @@ export const DetailedStatus: React.FC<{
|
|||||||
);
|
);
|
||||||
contentMedia.push(hashtagBar);
|
contentMedia.push(hashtagBar);
|
||||||
|
|
||||||
|
const matchedFilters = status.get('matched_filters');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={outerStyle}>
|
<div style={outerStyle}>
|
||||||
<div
|
<div
|
||||||
@@ -386,6 +394,15 @@ export const DetailedStatus: React.FC<{
|
|||||||
)}
|
)}
|
||||||
</Permalink>
|
</Permalink>
|
||||||
|
|
||||||
|
{matchedFilters && (
|
||||||
|
<FilterWarning
|
||||||
|
title={matchedFilters.join(', ')}
|
||||||
|
expanded={showDespiteFilter}
|
||||||
|
onClick={handleFilterToggle}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(!matchedFilters || showDespiteFilter) && (
|
||||||
<StatusContent
|
<StatusContent
|
||||||
status={status}
|
status={status}
|
||||||
media={contentMedia}
|
media={contentMedia}
|
||||||
@@ -402,6 +419,7 @@ export const DetailedStatus: React.FC<{
|
|||||||
disabled
|
disabled
|
||||||
{...(statusContentProps as any)}
|
{...(statusContentProps as any)}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className='detailed-status__meta'>
|
<div className='detailed-status__meta'>
|
||||||
<div className='detailed-status__meta__line'>
|
<div className='detailed-status__meta__line'>
|
||||||
|
|||||||
@@ -133,7 +133,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 = Immutable.List();
|
let ancestorsIds = Immutable.List();
|
||||||
let descendantsIds = Immutable.List();
|
let descendantsIds = Immutable.List();
|
||||||
|
|||||||
@@ -15,9 +15,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, accountBase, accountReblog, filters) => {
|
(statusBase, statusReblog, accountBase, accountReblog, filters, warnInsteadOfHide) => {
|
||||||
if (!statusBase || statusBase.get('isLoading')) {
|
if (!statusBase || statusBase.get('isLoading')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -25,7 +26,7 @@ export const makeGetStatus = () => {
|
|||||||
let filtered = false;
|
let filtered = false;
|
||||||
if ((accountReblog || accountBase).get('id') !== me && filters) {
|
if ((accountReblog || accountBase).get('id') !== me && filters) {
|
||||||
let filterResults = statusReblog?.get('filtered') || statusBase.get('filtered') || ImmutableList();
|
let filterResults = statusReblog?.get('filtered') || statusBase.get('filtered') || ImmutableList();
|
||||||
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')));
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ export const toServerSideType = (columnType: string) => {
|
|||||||
case 'thread':
|
case 'thread':
|
||||||
case 'account':
|
case 'account':
|
||||||
return columnType;
|
return columnType;
|
||||||
|
case 'detailed':
|
||||||
|
return 'thread';
|
||||||
default:
|
default:
|
||||||
if (columnType.includes('list:')) {
|
if (columnType.includes('list:')) {
|
||||||
return 'home';
|
return 'home';
|
||||||
|
|||||||
Reference in New Issue
Block a user