From 6997b91e4c894b7d55f8e2d303d4751d19410814 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Sun, 7 May 2023 21:44:41 -0500 Subject: [PATCH] Add the mute override when viewing a profile's posts --- src/lib/labeling/helpers.ts | 12 +++++++++--- src/lib/labeling/types.ts | 1 + src/view/com/posts/FeedItem.tsx | 18 +++++++++++++++--- src/view/com/posts/FeedSlice.tsx | 4 +++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/lib/labeling/helpers.ts b/src/lib/labeling/helpers.ts index 90f69a21d8..eb802a1db6 100644 --- a/src/lib/labeling/helpers.ts +++ b/src/lib/labeling/helpers.ts @@ -17,6 +17,7 @@ import { Label, LabelValGroup, ModerationBehaviorCode, + ModerationBehavior, PostModeration, ProfileModeration, PostLabelInfo, @@ -134,9 +135,9 @@ export function getPostModeration( } return { avatar, - list: hide(msg), - thread: warn(msg), - view: warn(msg), + list: isMute(hide(msg)), + thread: isMute(warn(msg)), + view: isMute(warn(msg)), } } @@ -422,6 +423,11 @@ function warnContent(reason: string) { } } +function isMute(behavior: ModerationBehavior): ModerationBehavior { + behavior.isMute = true + return behavior +} + // TODO // function warnImages(reason: string) { // return { diff --git a/src/lib/labeling/types.ts b/src/lib/labeling/types.ts index bb6b619800..dad6dae9a6 100644 --- a/src/lib/labeling/types.ts +++ b/src/lib/labeling/types.ts @@ -45,6 +45,7 @@ export enum ModerationBehaviorCode { export interface ModerationBehavior { behavior: ModerationBehaviorCode + isMute?: boolean noOverride?: boolean reason?: string } diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 10fc775c57..9aea05f73b 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -8,6 +8,7 @@ import { FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' import {PostsFeedItemModel} from 'state/models/feeds/posts' +import {ModerationBehaviorCode} from 'lib/labeling/types' import {Link, DesktopWebTextLink} from '../util/Link' import {Text} from '../util/text/Text' import {UserInfoText} from '../util/UserInfoText' @@ -30,13 +31,14 @@ export const FeedItem = observer(function ({ isThreadChild, isThreadParent, showFollowBtn, + ignoreMuteFor, }: { item: PostsFeedItemModel isThreadChild?: boolean isThreadParent?: boolean showReplyLine?: boolean showFollowBtn?: boolean - ignoreMuteFor?: string // NOTE currently disabled, will be addressed in the next PR -prf + ignoreMuteFor?: string }) { const store = useStores() const pal = usePalette('default') @@ -141,12 +143,22 @@ export const FeedItem = observer(function ({ isThreadParent ? styles.outerNoBottom : undefined, ] + // moderation override + let moderation = item.moderation.list + if ( + ignoreMuteFor === item.post.author.did && + moderation.isMute && + !moderation.noOverride + ) { + moderation = {behavior: ModerationBehaviorCode.Show} + } + return ( + moderation={moderation}> {isThreadChild && ( )} {item.richText?.text ? ( diff --git a/src/view/com/posts/FeedSlice.tsx b/src/view/com/posts/FeedSlice.tsx index 5a191ac102..824fd0c4bb 100644 --- a/src/view/com/posts/FeedSlice.tsx +++ b/src/view/com/posts/FeedSlice.tsx @@ -19,7 +19,9 @@ export function FeedSlice({ ignoreMuteFor?: string }) { if (slice.moderation.list.behavior === ModerationBehaviorCode.Hide) { - return null + if (!ignoreMuteFor && !slice.moderation.list.noOverride) { + return null + } } if (slice.isThread && slice.items.length > 3) { const last = slice.items.length - 1