import React from 'react' import {StyleProp, View, ViewStyle} from 'react-native' import { AppBskyFeedDefs, AppBskyFeedThreadgate, AppBskyGraphDefs, AtUri, } from '@atproto/api' import {Trans} from '@lingui/macro' import {usePalette} from '#/lib/hooks/usePalette' import {Text} from '../util/text/Text' import {TextLink} from '../util/Link' import {makeProfileLink, makeListLink} from '#/lib/routes/links' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {useColorSchemeStyle} from '#/lib/hooks/useColorSchemeStyle' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {colors} from '#/lib/styles' export function WhoCanReply({ post, style, }: { post: AppBskyFeedDefs.PostView style?: StyleProp }) { const pal = usePalette('default') const {isMobile} = useWebMediaQueries() const containerStyles = useColorSchemeStyle( { borderColor: pal.colors.unreadNotifBorder, backgroundColor: pal.colors.unreadNotifBg, }, { borderColor: pal.colors.unreadNotifBorder, backgroundColor: pal.colors.unreadNotifBg, }, ) const iconStyles = useColorSchemeStyle( { backgroundColor: colors.blue3, }, { backgroundColor: colors.blue3, }, ) const textStyles = useColorSchemeStyle( {color: colors.gray7}, {color: colors.blue1}, ) const record = React.useMemo( () => post.threadgate && AppBskyFeedThreadgate.isRecord(post.threadgate.record) && AppBskyFeedThreadgate.validateRecord(post.threadgate.record).success ? post.threadgate.record : null, [post], ) if (record) { return ( {!record.allow?.length ? ( Replies to this thread are disabled ) : ( Only{' '} {record.allow.map((rule, i) => ( <> ))}{' '} can reply. )} ) } return null } function Rule({ rule, post, lists, }: { rule: any post: AppBskyFeedDefs.PostView lists: AppBskyGraphDefs.ListViewBasic[] | undefined }) { const pal = usePalette('default') if (AppBskyFeedThreadgate.isMentionRule(rule)) { return mentioned users } if (AppBskyFeedThreadgate.isFollowingRule(rule)) { return ( users followed by{' '} ) } if (AppBskyFeedThreadgate.isListRule(rule)) { const list = lists?.find(l => l.uri === rule.list) if (list) { const listUrip = new AtUri(list.uri) return ( {' '} members ) } } } function Separator({i, length}: {i: number; length: number}) { if (length < 2 || i === length - 1) { return null } if (i === length - 2) { return ( <> {length > 2 ? ',' : ''} and{' '} ) } return <>, }