Merge remote-tracking branch 'origin/main' into hailey/referrer-sync

This commit is contained in:
Hailey
2024-07-12 06:55:03 -07:00
3 changed files with 85 additions and 56 deletions
@@ -1,11 +1,13 @@
import React from 'react'
import Picker from '@emoji-mart/react'
import {
StyleSheet,
GestureResponderEvent,
TouchableWithoutFeedback,
useWindowDimensions,
View,
} from 'react-native'
import Picker from '@emoji-mart/react'
import {atoms as a} from '#/alf'
import {textInputWebEmitter} from '../TextInput.web'
const HEIGHT_OFFSET = 40
@@ -96,12 +98,29 @@ export function EmojiPicker({state, close}: IProps) {
if (!state.isOpen) return null
const onPressBackdrop = (e: GestureResponderEvent) => {
// @ts-ignore web only
if (e.nativeEvent?.pointerId === -1) return
close()
}
return (
<TouchableWithoutFeedback
accessibilityRole="button"
onPress={close}
onPress={onPressBackdrop}
accessibilityViewIsModal>
<View style={styles.mask}>
<View
style={[
a.fixed,
a.w_full,
a.h_full,
a.align_center,
{
top: 0,
left: 0,
right: 0,
},
]}>
{/* eslint-disable-next-line react-native-a11y/has-valid-accessibility-descriptors */}
<TouchableWithoutFeedback onPress={e => e.stopPropagation()}>
<View style={[{position: 'absolute'}, position]}>
@@ -118,20 +137,3 @@ export function EmojiPicker({state, close}: IProps) {
</TouchableWithoutFeedback>
)
}
const styles = StyleSheet.create({
mask: {
// @ts-ignore web ony
position: 'fixed',
top: 0,
left: 0,
right: 0,
width: '100%',
height: '100%',
alignItems: 'center',
},
picker: {
marginHorizontal: 'auto',
paddingRight: 50,
},
})
+19 -11
View File
@@ -15,6 +15,7 @@ import {useQueryClient} from '@tanstack/react-query'
import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useSession} from '#/state/session'
import {useComposerControls} from '#/state/shell/composer'
import {MAX_POST_LINES} from 'lib/constants'
import {usePalette} from 'lib/hooks/usePalette'
@@ -145,6 +146,9 @@ function PostInner({
precacheProfile(queryClient, post.author)
}, [queryClient, post.author])
const {currentAccount} = useSession()
const isMe = replyAuthorDid === currentAccount?.did
return (
<Link
href={itemHref}
@@ -187,17 +191,21 @@ function PostInner({
style={[pal.textLight, s.mr2]}
lineHeight={1.2}
numberOfLines={1}>
<Trans context="description">
Reply to{' '}
<ProfileHoverCard inline did={replyAuthorDid}>
<UserInfoText
type="sm"
did={replyAuthorDid}
attr="displayName"
style={[pal.textLight]}
/>
</ProfileHoverCard>
</Trans>
{isMe ? (
<Trans context="description">Reply to you</Trans>
) : (
<Trans context="description">
Reply to{' '}
<ProfileHoverCard inline did={replyAuthorDid}>
<UserInfoText
type="sm"
did={replyAuthorDid}
attr="displayName"
style={[pal.textLight]}
/>
</ProfileHoverCard>
</Trans>
)}
</Text>
</View>
)}
+43 -24
View File
@@ -43,6 +43,7 @@ import {Text} from '../util/text/Text'
import {PreviewableUserAvatar} from '../util/UserAvatar'
import {AviFollowButton} from './AviFollowButton'
import hairlineWidth = StyleSheet.hairlineWidth
import {useSession} from '#/state/session'
import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost'
interface FeedItemProps {
@@ -200,6 +201,11 @@ let FeedItemInner = ({
},
]
const {currentAccount} = useSession()
const isOwner =
AppBskyFeedDefs.isReasonRepost(reason) &&
reason.by.did === currentAccount?.did
return (
<Link
testID={`feedItem-by-${post.author.handle}`}
@@ -250,11 +256,15 @@ let FeedItemInner = ({
<Link
style={styles.includeReason}
href={makeProfileLink(reason.by)}
title={_(
msg`Reposted by ${sanitizeDisplayName(
reason.by.displayName || reason.by.handle,
)}`,
)}
title={
isOwner
? _(msg`Reposted by you`)
: _(
msg`Reposted by ${sanitizeDisplayName(
reason.by.displayName || reason.by.handle,
)}`,
)
}
onBeforePress={onOpenReposter}>
<Repost
style={{color: pal.colors.textLight, marginRight: 3}}
@@ -266,24 +276,28 @@ let FeedItemInner = ({
style={pal.textLight}
lineHeight={1.2}
numberOfLines={1}>
<Trans>
Reposted by{' '}
<ProfileHoverCard inline did={reason.by.did}>
<TextLinkOnWebOnly
type="sm-bold"
style={pal.textLight}
lineHeight={1.2}
numberOfLines={1}
text={sanitizeDisplayName(
reason.by.displayName ||
sanitizeHandle(reason.by.handle),
moderation.ui('displayName'),
)}
href={makeProfileLink(reason.by)}
onBeforePress={onOpenReposter}
/>
</ProfileHoverCard>
</Trans>
{isOwner ? (
<Trans>Reposted by you</Trans>
) : (
<Trans>
Reposted by{' '}
<ProfileHoverCard inline did={reason.by.did}>
<TextLinkOnWebOnly
type="sm-bold"
style={pal.textLight}
lineHeight={1.2}
numberOfLines={1}
text={sanitizeDisplayName(
reason.by.displayName ||
sanitizeHandle(reason.by.handle),
moderation.ui('displayName'),
)}
href={makeProfileLink(reason.by)}
onBeforePress={onOpenReposter}
/>
</ProfileHoverCard>
</Trans>
)}
</Text>
</Link>
) : null}
@@ -421,6 +435,9 @@ function ReplyToLabel({
blocked?: boolean
}) {
const pal = usePalette('default')
const {currentAccount} = useSession()
const isMe = profile.did === currentAccount?.did
return (
<View style={[s.flexRow, s.mb2, s.alignCenter]}>
<FontAwesomeIcon
@@ -433,7 +450,9 @@ function ReplyToLabel({
style={[pal.textLight, s.mr2]}
lineHeight={1.2}
numberOfLines={1}>
{blocked ? (
{isMe ? (
<Trans context="description">Reply to you</Trans>
) : blocked ? (
<Trans context="description">Reply to a blocked post</Trans>
) : (
<Trans context="description">