diff options
Diffstat (limited to 'src/view/com/util/post-ctrls/PostCtrls.tsx')
-rw-r--r-- | src/view/com/util/post-ctrls/PostCtrls.tsx | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 7ebcde9a0..b6c07d573 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -23,6 +23,7 @@ import {toShareUrl} from '#/lib/strings/url-helpers' import {s} from '#/lib/styles' import {useTheme} from '#/lib/ThemeContext' import {Shadow} from '#/state/cache/types' +import {useFeedFeedbackContext} from '#/state/feed-feedback' import {useModalControls} from '#/state/modals' import { usePostLikeMutationQueue, @@ -43,6 +44,7 @@ let PostCtrls = ({ post, record, richText, + feedContext, style, onPressReply, logContext, @@ -51,6 +53,7 @@ let PostCtrls = ({ post: Shadow<AppBskyFeedDefs.PostView> record: AppBskyFeedPost.Record richText: RichTextAPI + feedContext?: string | undefined style?: StyleProp<ViewStyle> onPressReply: () => void logContext: 'FeedItem' | 'PostThreadItem' | 'Post' @@ -66,6 +69,7 @@ let PostCtrls = ({ ) const requireAuth = useRequireAuth() const loggedOutWarningPromptControl = useDialogControl() + const {sendInteraction} = useFeedFeedbackContext() const playHaptic = useHaptics() const shouldShowLoggedOutWarning = React.useMemo(() => { @@ -85,6 +89,11 @@ let PostCtrls = ({ try { if (!post.viewer?.like) { playHaptic() + sendInteraction({ + item: post.uri, + event: 'app.bsky.feed.defs#interactionLike', + feedContext, + }) await queueLike() } else { await queueUnlike() @@ -94,13 +103,26 @@ let PostCtrls = ({ throw e } } - }, [playHaptic, post.viewer?.like, queueLike, queueUnlike]) + }, [ + playHaptic, + post.uri, + post.viewer?.like, + queueLike, + queueUnlike, + sendInteraction, + feedContext, + ]) const onRepost = useCallback(async () => { closeModal() try { if (!post.viewer?.repost) { playHaptic() + sendInteraction({ + item: post.uri, + event: 'app.bsky.feed.defs#interactionRepost', + feedContext, + }) await queueRepost() } else { await queueUnrepost() @@ -110,10 +132,24 @@ let PostCtrls = ({ throw e } } - }, [closeModal, post.viewer?.repost, playHaptic, queueRepost, queueUnrepost]) + }, [ + closeModal, + post.uri, + post.viewer?.repost, + playHaptic, + queueRepost, + queueUnrepost, + sendInteraction, + feedContext, + ]) const onQuote = useCallback(() => { closeModal() + sendInteraction({ + item: post.uri, + event: 'app.bsky.feed.defs#interactionQuote', + feedContext, + }) openComposer({ quote: { uri: post.uri, @@ -133,6 +169,8 @@ let PostCtrls = ({ post.indexedAt, record.text, playHaptic, + sendInteraction, + feedContext, ]) const onShare = useCallback(() => { @@ -140,7 +178,12 @@ let PostCtrls = ({ const href = makeProfileLink(post.author, 'post', urip.rkey) const url = toShareUrl(href) shareUrl(url) - }, [post.uri, post.author]) + sendInteraction({ + item: post.uri, + event: 'app.bsky.feed.defs#interactionShare', + feedContext, + }) + }, [post.uri, post.author, sendInteraction, feedContext]) return ( <View style={[styles.ctrls, style]}> @@ -268,6 +311,7 @@ let PostCtrls = ({ postAuthor={post.author} postCid={post.cid} postUri={post.uri} + postFeedContext={feedContext} record={record} richText={richText} style={styles.btnPad} |