From 0c9dc2163ab5102e58f13597ba84e14717e09ffd Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 27 Dec 2023 08:48:23 -0800 Subject: [PATCH] Fix: only show appeal CW item on moderated posts (#2312) * Fix: only show appeal CW item on moderated posts * Add appeal cw control to feed view o fposts --- src/view/com/post-thread/PostThreadItem.tsx | 6 +++--- src/view/com/posts/FeedItem.tsx | 14 +++++++++++++- src/view/com/util/post-ctrls/PostCtrls.tsx | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 6a377cdf..13f40bb1 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -186,9 +186,9 @@ let PostThreadItemLoaded = ({ return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by') }, [post.uri, post.author]) const repostsTitle = 'Reposts of this post' - const isSelfLabeledPost = + const isModeratedPost = moderation.decisions.post.cause?.type === 'label' && - moderation.decisions.post.cause.label.src === currentAccount?.did + moderation.decisions.post.cause.label.src !== currentAccount?.did const translatorUrl = getTranslatorLink( record?.text || '', @@ -335,7 +335,7 @@ let PostThreadItemLoaded = ({ postUri={post.uri} record={record} showAppealLabelItem={ - post.author.did === currentAccount?.did && !isSelfLabeledPost + post.author.did === currentAccount?.did && isModeratedPost } style={{ paddingVertical: 6, diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 2be31426..942d7bf7 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -34,6 +34,7 @@ import {countLines} from 'lib/strings/helpers' import {useComposerControls} from '#/state/shell/composer' import {Shadow, usePostShadow, POST_TOMBSTONE} from '#/state/cache/post-shadow' import {FeedNameText} from '../util/FeedInfoText' +import {useSession} from '#/state/session' export function FeedItem({ post, @@ -102,10 +103,14 @@ let FeedItemInner = ({ }): React.ReactNode => { const {openComposer} = useComposerControls() const pal = usePalette('default') + const {currentAccount} = useSession() const href = useMemo(() => { const urip = new AtUri(post.uri) return makeProfileLink(post.author, 'post', urip.rkey) }, [post.uri, post.author]) + const isModeratedPost = + moderation.decisions.post.cause?.type === 'label' && + moderation.decisions.post.cause.label.src !== currentAccount?.did const replyAuthorDid = useMemo(() => { if (!record?.reply) { @@ -284,7 +289,14 @@ let FeedItemInner = ({ postEmbed={post.embed} postAuthor={post.author} /> - + diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 414fb1e0..a50b5217 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -31,12 +31,14 @@ let PostCtrls = ({ big, post, record, + showAppealLabelItem, style, onPressReply, }: { big?: boolean post: Shadow record: AppBskyFeedPost.Record + showAppealLabelItem?: boolean style?: StyleProp onPressReply: () => void }): React.ReactNode => { @@ -207,6 +209,7 @@ let PostCtrls = ({ postCid={post.cid} postUri={post.uri} record={record} + showAppealLabelItem={showAppealLabelItem} style={styles.ctrlPad} /> )}