Skip to content

Commit

Permalink
Fix: only show appeal CW item on moderated posts (#2312)
Browse files Browse the repository at this point in the history
* Fix: only show appeal CW item on moderated posts

* Add appeal cw control to feed view o fposts
  • Loading branch information
pfrazee authored Dec 27, 2023
1 parent 6e001db commit 0c9dc21
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/view/com/post-thread/PostThreadItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '',
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 13 additions & 1 deletion src/view/com/posts/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -284,7 +289,14 @@ let FeedItemInner = ({
postEmbed={post.embed}
postAuthor={post.author}
/>
<PostCtrls post={post} record={record} onPressReply={onPressReply} />
<PostCtrls
post={post}
record={record}
onPressReply={onPressReply}
showAppealLabelItem={
post.author.did === currentAccount?.did && isModeratedPost
}
/>
</View>
</View>
</Link>
Expand Down
3 changes: 3 additions & 0 deletions src/view/com/util/post-ctrls/PostCtrls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ let PostCtrls = ({
big,
post,
record,
showAppealLabelItem,
style,
onPressReply,
}: {
big?: boolean
post: Shadow<AppBskyFeedDefs.PostView>
record: AppBskyFeedPost.Record
showAppealLabelItem?: boolean
style?: StyleProp<ViewStyle>
onPressReply: () => void
}): React.ReactNode => {
Expand Down Expand Up @@ -207,6 +209,7 @@ let PostCtrls = ({
postCid={post.cid}
postUri={post.uri}
record={record}
showAppealLabelItem={showAppealLabelItem}
style={styles.ctrlPad}
/>
)}
Expand Down

0 comments on commit 0c9dc21

Please sign in to comment.