Thread through threadgate record, validate approach

This commit is contained in:
Eric Bailey
2024-08-05 09:55:59 -05:00
parent 380c4dbf24
commit 571d00cf41
5 changed files with 64 additions and 3 deletions
+23 -1
View File
@@ -31,7 +31,8 @@ import {
usePostDeleteMutation,
useThreadMuteMutationQueue,
} from '#/state/queries/post'
import {useSession} from '#/state/session'
import {createThreadgate} from '#/state/queries/threadgate'
import {useAgent, useSession} from '#/state/session'
import {getCurrentRoute} from 'lib/routes/helpers'
import {shareUrl} from 'lib/sharing'
import {toShareUrl} from 'lib/strings/url-helpers'
@@ -73,6 +74,7 @@ let PostDropdownBtn = ({
hitSlop,
size,
timestamp,
rootPostUri,
}: {
testID: string
post: Shadow<AppBskyFeedDefs.PostView>
@@ -83,8 +85,10 @@ let PostDropdownBtn = ({
hitSlop?: PressableProps['hitSlop']
size?: 'lg' | 'md' | 'sm'
timestamp: string
rootPostUri?: string
}): React.ReactNode => {
const {hasSession, currentAccount} = useSession()
const agent = useAgent()
const theme = useTheme()
const alf = useAlf()
const {gtMobile} = useBreakpoints()
@@ -393,6 +397,24 @@ let PostDropdownBtn = ({
<Menu.ItemIcon icon={EyeSlash} position="right" />
</Menu.Item>
)}
{!isAuthor && !isPostHidden && rootPostUri && (
<Menu.Item
testID="postDropdownHideBtn"
label={_(msg`Hide reply`)}
onPress={() => {
createThreadgate({
agent,
postUri: rootPostUri,
threadgate: {
hiddenReplies: [postUri],
},
})
}}>
<Menu.ItemText>{_(msg`Hide reply`)}</Menu.ItemText>
<Menu.ItemIcon icon={EyeSlash} position="right" />
</Menu.Item>
)}
</Menu.Group>
</>
)}
@@ -59,6 +59,7 @@ let PostCtrls = ({
style,
onPressReply,
logContext,
rootPostUri,
}: {
big?: boolean
post: Shadow<AppBskyFeedDefs.PostView>
@@ -68,6 +69,7 @@ let PostCtrls = ({
style?: StyleProp<ViewStyle>
onPressReply: () => void
logContext: 'FeedItem' | 'PostThreadItem' | 'Post'
rootPostUri?: string
}): React.ReactNode => {
const t = useTheme()
const {_} = useLingui()
@@ -338,6 +340,7 @@ let PostCtrls = ({
style={{padding: 5}}
hitSlop={POST_CTRL_HITSLOP}
timestamp={post.indexedAt}
rootPostUri={rootPostUri}
/>
</View>
{gate('debug_show_feedcontext') && feedContext && (