mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-17 09:48:42 +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:
@@ -15,6 +15,7 @@ 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 { ContentWarning } from 'flavours/glitch/components/content_warning';
|
import { ContentWarning } from 'flavours/glitch/components/content_warning';
|
||||||
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';
|
||||||
@@ -74,6 +75,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 rewriteMentions = useAppSelector(
|
const rewriteMentions = useAppSelector(
|
||||||
@@ -102,6 +104,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]);
|
||||||
@@ -320,7 +326,11 @@ export const DetailedStatus: React.FC<{
|
|||||||
status as StatusLike,
|
status as StatusLike,
|
||||||
);
|
);
|
||||||
|
|
||||||
expanded ||= status.get('spoiler_text').length === 0;
|
const matchedFilters = status.get('matched_filters');
|
||||||
|
|
||||||
|
expanded =
|
||||||
|
(!matchedFilters || showDespiteFilter) &&
|
||||||
|
(expanded || status.get('spoiler_text').length === 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={outerStyle}>
|
<div style={outerStyle}>
|
||||||
@@ -354,7 +364,16 @@ export const DetailedStatus: React.FC<{
|
|||||||
)}
|
)}
|
||||||
</Permalink>
|
</Permalink>
|
||||||
|
|
||||||
{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']) ||
|
||||||
|
|||||||
@@ -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 = ImmutableList();
|
let ancestorsIds = ImmutableList();
|
||||||
let descendantsIds = ImmutableList();
|
let descendantsIds = ImmutableList();
|
||||||
|
|||||||
@@ -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