Add the mute override when viewing a profile's posts

This commit is contained in:
Paul Frazee
2023-05-07 21:44:41 -05:00
parent bb5026b2e9
commit 6997b91e4c
4 changed files with 28 additions and 7 deletions
+9 -3
View File
@@ -17,6 +17,7 @@ import {
Label, Label,
LabelValGroup, LabelValGroup,
ModerationBehaviorCode, ModerationBehaviorCode,
ModerationBehavior,
PostModeration, PostModeration,
ProfileModeration, ProfileModeration,
PostLabelInfo, PostLabelInfo,
@@ -134,9 +135,9 @@ export function getPostModeration(
} }
return { return {
avatar, avatar,
list: hide(msg), list: isMute(hide(msg)),
thread: warn(msg), thread: isMute(warn(msg)),
view: 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 // TODO
// function warnImages(reason: string) { // function warnImages(reason: string) {
// return { // return {
+1
View File
@@ -45,6 +45,7 @@ export enum ModerationBehaviorCode {
export interface ModerationBehavior { export interface ModerationBehavior {
behavior: ModerationBehaviorCode behavior: ModerationBehaviorCode
isMute?: boolean
noOverride?: boolean noOverride?: boolean
reason?: string reason?: string
} }
+15 -3
View File
@@ -8,6 +8,7 @@ import {
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import {PostsFeedItemModel} from 'state/models/feeds/posts' import {PostsFeedItemModel} from 'state/models/feeds/posts'
import {ModerationBehaviorCode} from 'lib/labeling/types'
import {Link, DesktopWebTextLink} from '../util/Link' import {Link, DesktopWebTextLink} from '../util/Link'
import {Text} from '../util/text/Text' import {Text} from '../util/text/Text'
import {UserInfoText} from '../util/UserInfoText' import {UserInfoText} from '../util/UserInfoText'
@@ -30,13 +31,14 @@ export const FeedItem = observer(function ({
isThreadChild, isThreadChild,
isThreadParent, isThreadParent,
showFollowBtn, showFollowBtn,
ignoreMuteFor,
}: { }: {
item: PostsFeedItemModel item: PostsFeedItemModel
isThreadChild?: boolean isThreadChild?: boolean
isThreadParent?: boolean isThreadParent?: boolean
showReplyLine?: boolean showReplyLine?: boolean
showFollowBtn?: boolean showFollowBtn?: boolean
ignoreMuteFor?: string // NOTE currently disabled, will be addressed in the next PR -prf ignoreMuteFor?: string
}) { }) {
const store = useStores() const store = useStores()
const pal = usePalette('default') const pal = usePalette('default')
@@ -141,12 +143,22 @@ export const FeedItem = observer(function ({
isThreadParent ? styles.outerNoBottom : undefined, 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 ( return (
<PostHider <PostHider
testID={`feedItem-by-${item.post.author.handle}`} testID={`feedItem-by-${item.post.author.handle}`}
style={outerStyles} style={outerStyles}
href={itemHref} href={itemHref}
moderation={item.moderation.list}> moderation={moderation}>
{isThreadChild && ( {isThreadChild && (
<View <View
style={[styles.topReplyLine, {borderColor: pal.colors.replyLine}]} style={[styles.topReplyLine, {borderColor: pal.colors.replyLine}]}
@@ -232,7 +244,7 @@ export const FeedItem = observer(function ({
</View> </View>
)} )}
<ContentHider <ContentHider
moderation={item.moderation.list} moderation={moderation}
containerStyle={styles.contentHider}> containerStyle={styles.contentHider}>
{item.richText?.text ? ( {item.richText?.text ? (
<View style={styles.postTextContainer}> <View style={styles.postTextContainer}>
+2
View File
@@ -19,8 +19,10 @@ export function FeedSlice({
ignoreMuteFor?: string ignoreMuteFor?: string
}) { }) {
if (slice.moderation.list.behavior === ModerationBehaviorCode.Hide) { if (slice.moderation.list.behavior === ModerationBehaviorCode.Hide) {
if (!ignoreMuteFor && !slice.moderation.list.noOverride) {
return null return null
} }
}
if (slice.isThread && slice.items.length > 3) { if (slice.isThread && slice.items.length > 3) {
const last = slice.items.length - 1 const last = slice.items.length - 1
return ( return (