add reqId to feed feedback (#8396)
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -103,6 +103,7 @@ type FeedRow =
|
||||
items: FeedPostSliceItem[]
|
||||
sourceFeedUri: string
|
||||
feedContexts: (string | undefined)[]
|
||||
reqIds: (string | undefined)[]
|
||||
}
|
||||
| {
|
||||
type: 'sliceViewFullThread'
|
||||
@@ -134,16 +135,19 @@ export function getItemsForFeedback(feedRow: FeedRow):
|
||||
| {
|
||||
item: FeedPostSliceItem
|
||||
feedContext: string | undefined
|
||||
reqId: string | undefined
|
||||
}[] {
|
||||
if (feedRow.type === 'sliceItem') {
|
||||
return feedRow.slice.items.map(item => ({
|
||||
item,
|
||||
feedContext: feedRow.slice.feedContext,
|
||||
reqId: feedRow.slice.reqId,
|
||||
}))
|
||||
} else if (feedRow.type === 'videoGridRow') {
|
||||
return feedRow.items.map((item, i) => ({
|
||||
item,
|
||||
feedContext: feedRow.feedContexts[i],
|
||||
reqId: feedRow.reqIds[i],
|
||||
}))
|
||||
} else {
|
||||
return []
|
||||
@@ -398,6 +402,7 @@ let PostFeed = ({
|
||||
const videos: {
|
||||
item: FeedPostSliceItem
|
||||
feedContext: string | undefined
|
||||
reqId: string | undefined
|
||||
}[] = []
|
||||
for (const page of data.pages) {
|
||||
for (const slice of page.slices) {
|
||||
@@ -405,7 +410,11 @@ let PostFeed = ({
|
||||
item => item.uri === slice.feedPostUri,
|
||||
)
|
||||
if (item && AppBskyEmbedVideo.isView(item.post.embed)) {
|
||||
videos.push({item, feedContext: slice.feedContext})
|
||||
videos.push({
|
||||
item,
|
||||
feedContext: slice.feedContext,
|
||||
reqId: slice.reqId,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,12 +422,17 @@ let PostFeed = ({
|
||||
const rows: {
|
||||
item: FeedPostSliceItem
|
||||
feedContext: string | undefined
|
||||
reqId: string | undefined
|
||||
}[][] = []
|
||||
for (let i = 0; i < videos.length; i++) {
|
||||
const video = videos[i]
|
||||
const item = video.item
|
||||
const cols = gtMobile ? 3 : 2
|
||||
const rowItem = {item, feedContext: video.feedContext}
|
||||
const rowItem = {
|
||||
item,
|
||||
feedContext: video.feedContext,
|
||||
reqId: video.reqId,
|
||||
}
|
||||
if (i % cols === 0) {
|
||||
rows.push([rowItem])
|
||||
} else {
|
||||
@@ -434,6 +448,7 @@ let PostFeed = ({
|
||||
items: row.map(r => r.item),
|
||||
sourceFeedUri: feedUriOrActorDid,
|
||||
feedContexts: row.map(r => r.feedContext),
|
||||
reqIds: row.map(r => r.reqId),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@@ -685,6 +700,7 @@ let PostFeed = ({
|
||||
record={item.record}
|
||||
reason={indexInSlice === 0 ? slice.reason : undefined}
|
||||
feedContext={slice.feedContext}
|
||||
reqId={slice.reqId}
|
||||
moderation={item.moderation}
|
||||
parentAuthor={item.parentAuthor}
|
||||
showReplyTo={row.showReplyTo}
|
||||
|
||||
@@ -70,6 +70,7 @@ interface FeedItemProps {
|
||||
isThreadLastChild?: boolean
|
||||
isThreadParent?: boolean
|
||||
feedContext: string | undefined
|
||||
reqId: string | undefined
|
||||
hideTopBorder?: boolean
|
||||
isParentBlocked?: boolean
|
||||
isParentNotFound?: boolean
|
||||
@@ -80,6 +81,7 @@ export function PostFeedItem({
|
||||
record,
|
||||
reason,
|
||||
feedContext,
|
||||
reqId,
|
||||
moderation,
|
||||
parentAuthor,
|
||||
showReplyTo,
|
||||
@@ -117,6 +119,7 @@ export function PostFeedItem({
|
||||
record={record}
|
||||
reason={reason}
|
||||
feedContext={feedContext}
|
||||
reqId={reqId}
|
||||
richText={richText}
|
||||
parentAuthor={parentAuthor}
|
||||
showReplyTo={showReplyTo}
|
||||
@@ -140,6 +143,7 @@ let FeedItemInner = ({
|
||||
record,
|
||||
reason,
|
||||
feedContext,
|
||||
reqId,
|
||||
richText,
|
||||
moderation,
|
||||
parentAuthor,
|
||||
@@ -171,11 +175,12 @@ let FeedItemInner = ({
|
||||
}, [post.uri, post.author])
|
||||
const {sendInteraction} = useFeedFeedbackContext()
|
||||
|
||||
const onPressReply = useCallback(() => {
|
||||
const onPressReply = () => {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionReply',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
openComposer({
|
||||
replyTo: {
|
||||
@@ -187,40 +192,44 @@ let FeedItemInner = ({
|
||||
moderation,
|
||||
},
|
||||
})
|
||||
}, [post, record, openComposer, moderation, sendInteraction, feedContext])
|
||||
}
|
||||
|
||||
const onOpenAuthor = useCallback(() => {
|
||||
const onOpenAuthor = () => {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#clickthroughAuthor',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
}, [sendInteraction, post, feedContext])
|
||||
}
|
||||
|
||||
const onOpenReposter = useCallback(() => {
|
||||
const onOpenReposter = () => {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#clickthroughReposter',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
}, [sendInteraction, post, feedContext])
|
||||
}
|
||||
|
||||
const onOpenEmbed = useCallback(() => {
|
||||
const onOpenEmbed = () => {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#clickthroughEmbed',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
}, [sendInteraction, post, feedContext])
|
||||
}
|
||||
|
||||
const onBeforePress = useCallback(() => {
|
||||
const onBeforePress = () => {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#clickthroughItem',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
precacheProfile(queryClient, post.author)
|
||||
}, [queryClient, post, sendInteraction, feedContext])
|
||||
}
|
||||
|
||||
const outerStyles = [
|
||||
styles.outer,
|
||||
@@ -437,6 +446,7 @@ let FeedItemInner = ({
|
||||
onPressReply={onPressReply}
|
||||
logContext="FeedItem"
|
||||
feedContext={feedContext}
|
||||
reqId={reqId}
|
||||
threadgateRecord={threadgateRecord}
|
||||
onShowLess={onShowLess}
|
||||
/>
|
||||
|
||||
@@ -28,6 +28,7 @@ let PostDropdownBtn = ({
|
||||
testID,
|
||||
post,
|
||||
postFeedContext,
|
||||
postReqId,
|
||||
record,
|
||||
richText,
|
||||
style,
|
||||
@@ -40,6 +41,7 @@ let PostDropdownBtn = ({
|
||||
testID: string
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
postFeedContext: string | undefined
|
||||
postReqId: string | undefined
|
||||
record: AppBskyFeedPost.Record
|
||||
richText: RichTextAPI
|
||||
style?: StyleProp<ViewStyle>
|
||||
@@ -99,6 +101,7 @@ let PostDropdownBtn = ({
|
||||
testID={testID}
|
||||
post={post}
|
||||
postFeedContext={postFeedContext}
|
||||
postReqId={postReqId}
|
||||
record={record}
|
||||
richText={richText}
|
||||
timestamp={timestamp}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {memo, useCallback} from 'react'
|
||||
import React, {memo} from 'react'
|
||||
import {
|
||||
Platform,
|
||||
type PressableProps,
|
||||
@@ -97,6 +97,7 @@ import * as Toast from '../Toast'
|
||||
let PostDropdownMenuItems = ({
|
||||
post,
|
||||
postFeedContext,
|
||||
postReqId,
|
||||
record,
|
||||
richText,
|
||||
timestamp,
|
||||
@@ -106,6 +107,7 @@ let PostDropdownMenuItems = ({
|
||||
testID: string
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
postFeedContext: string | undefined
|
||||
postReqId: string | undefined
|
||||
record: AppBskyFeedPost.Record
|
||||
richText: RichTextAPI
|
||||
style?: StyleProp<ViewStyle>
|
||||
@@ -189,7 +191,7 @@ let PostDropdownMenuItems = ({
|
||||
langPrefs.primaryLanguage,
|
||||
)
|
||||
|
||||
const onDeletePost = React.useCallback(() => {
|
||||
const onDeletePost = () => {
|
||||
deletePostMutate({uri: postUri}).then(
|
||||
() => {
|
||||
Toast.show(_(msg({message: 'Post deleted', context: 'toast'})))
|
||||
@@ -215,18 +217,9 @@ let PostDropdownMenuItems = ({
|
||||
Toast.show(_(msg`Failed to delete post, please try again`), 'xmark')
|
||||
},
|
||||
)
|
||||
}, [
|
||||
navigation,
|
||||
postUri,
|
||||
deletePostMutate,
|
||||
postAuthor,
|
||||
currentAccount,
|
||||
isAuthor,
|
||||
href,
|
||||
_,
|
||||
])
|
||||
}
|
||||
|
||||
const onToggleThreadMute = React.useCallback(() => {
|
||||
const onToggleThreadMute = () => {
|
||||
try {
|
||||
if (isThreadMuted) {
|
||||
unmuteThread()
|
||||
@@ -246,16 +239,16 @@ let PostDropdownMenuItems = ({
|
||||
)
|
||||
}
|
||||
}
|
||||
}, [isThreadMuted, unmuteThread, _, muteThread])
|
||||
}
|
||||
|
||||
const onCopyPostText = React.useCallback(() => {
|
||||
const onCopyPostText = () => {
|
||||
const str = richTextToString(richText, true)
|
||||
|
||||
Clipboard.setStringAsync(str)
|
||||
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
|
||||
}, [_, richText])
|
||||
}
|
||||
|
||||
const onPressTranslate = React.useCallback(async () => {
|
||||
const onPressTranslate = async () => {
|
||||
await openLink(translatorUrl, true)
|
||||
|
||||
if (
|
||||
@@ -270,40 +263,40 @@ let PostDropdownMenuItems = ({
|
||||
textLength: post.record.text.length,
|
||||
})
|
||||
}
|
||||
}, [openLink, translatorUrl, langPrefs, post])
|
||||
}
|
||||
|
||||
const onHidePost = React.useCallback(() => {
|
||||
const onHidePost = () => {
|
||||
hidePost({uri: postUri})
|
||||
}, [postUri, hidePost])
|
||||
}
|
||||
|
||||
const hideInPWI = React.useMemo(() => {
|
||||
return !!postAuthor.labels?.find(
|
||||
label => label.val === '!no-unauthenticated',
|
||||
)
|
||||
}, [postAuthor])
|
||||
const hideInPWI = !!postAuthor.labels?.find(
|
||||
label => label.val === '!no-unauthenticated',
|
||||
)
|
||||
|
||||
const showLoggedOutWarning =
|
||||
postAuthor.did !== currentAccount?.did && hideInPWI
|
||||
|
||||
const onSharePost = React.useCallback(() => {
|
||||
const onSharePost = () => {
|
||||
const url = toShareUrl(href)
|
||||
shareUrl(url)
|
||||
}, [href])
|
||||
}
|
||||
|
||||
const onPressShowMore = React.useCallback(() => {
|
||||
const onPressShowMore = () => {
|
||||
feedFeedback.sendInteraction({
|
||||
event: 'app.bsky.feed.defs#requestMore',
|
||||
item: postUri,
|
||||
feedContext: postFeedContext,
|
||||
reqId: postReqId,
|
||||
})
|
||||
Toast.show(_(msg({message: 'Feedback sent!', context: 'toast'})))
|
||||
}, [feedFeedback, postUri, postFeedContext, _])
|
||||
}
|
||||
|
||||
const onPressShowLess = React.useCallback(() => {
|
||||
const onPressShowLess = () => {
|
||||
feedFeedback.sendInteraction({
|
||||
event: 'app.bsky.feed.defs#requestLess',
|
||||
item: postUri,
|
||||
feedContext: postFeedContext,
|
||||
reqId: postReqId,
|
||||
})
|
||||
if (onShowLess) {
|
||||
onShowLess({
|
||||
@@ -313,19 +306,16 @@ let PostDropdownMenuItems = ({
|
||||
} else {
|
||||
Toast.show(_(msg({message: 'Feedback sent!', context: 'toast'})))
|
||||
}
|
||||
}, [feedFeedback, postUri, postFeedContext, _, onShowLess])
|
||||
}
|
||||
|
||||
const onSelectChatToShareTo = React.useCallback(
|
||||
(conversation: string) => {
|
||||
navigation.navigate('MessagesConversation', {
|
||||
conversation,
|
||||
embed: postUri,
|
||||
})
|
||||
},
|
||||
[navigation, postUri],
|
||||
)
|
||||
const onSelectChatToShareTo = (conversation: string) => {
|
||||
navigation.navigate('MessagesConversation', {
|
||||
conversation,
|
||||
embed: postUri,
|
||||
})
|
||||
}
|
||||
|
||||
const onToggleQuotePostAttachment = React.useCallback(async () => {
|
||||
const onToggleQuotePostAttachment = async () => {
|
||||
if (!quoteEmbed) return
|
||||
|
||||
const action = quoteEmbed.isDetached ? 'reattach' : 'detach'
|
||||
@@ -348,7 +338,7 @@ let PostDropdownMenuItems = ({
|
||||
)
|
||||
logger.error(`Failed to ${action} quote`, {safeMessage: e.message})
|
||||
}
|
||||
}, [_, quoteEmbed, post, toggleQuoteDetachment])
|
||||
}
|
||||
|
||||
const canHidePostForMe = !isAuthor && !isPostHidden
|
||||
const canEmbed = isWeb && gtMobile && !hideInPWI
|
||||
@@ -356,7 +346,7 @@ let PostDropdownMenuItems = ({
|
||||
!isAuthor && isRootPostAuthor && !isPostHidden && isReply
|
||||
const canDetachQuote = quoteEmbed && quoteEmbed.isOwnedByViewer
|
||||
|
||||
const onToggleReplyVisibility = React.useCallback(async () => {
|
||||
const onToggleReplyVisibility = async () => {
|
||||
// TODO no threadgate?
|
||||
if (!canHideReplyForEveryone) return
|
||||
|
||||
@@ -380,25 +370,18 @@ let PostDropdownMenuItems = ({
|
||||
)
|
||||
logger.error(`Failed to ${action} reply`, {safeMessage: e.message})
|
||||
}
|
||||
}, [
|
||||
_,
|
||||
isReplyHiddenByThreadgate,
|
||||
rootUri,
|
||||
postUri,
|
||||
canHideReplyForEveryone,
|
||||
toggleReplyVisibility,
|
||||
])
|
||||
}
|
||||
|
||||
const onPressPin = useCallback(() => {
|
||||
const onPressPin = () => {
|
||||
logEvent(isPinned ? 'post:unpin' : 'post:pin', {})
|
||||
pinPostMutate({
|
||||
postUri,
|
||||
postCid,
|
||||
action: isPinned ? 'unpin' : 'pin',
|
||||
})
|
||||
}, [isPinned, pinPostMutate, postCid, postUri])
|
||||
}
|
||||
|
||||
const onBlockAuthor = useCallback(async () => {
|
||||
const onBlockAuthor = async () => {
|
||||
try {
|
||||
await queueBlock()
|
||||
Toast.show(_(msg({message: 'Account blocked', context: 'toast'})))
|
||||
@@ -408,9 +391,9 @@ let PostDropdownMenuItems = ({
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
|
||||
}
|
||||
}
|
||||
}, [_, queueBlock])
|
||||
}
|
||||
|
||||
const onMuteAuthor = useCallback(async () => {
|
||||
const onMuteAuthor = async () => {
|
||||
if (postAuthor.viewer?.muted) {
|
||||
try {
|
||||
await queueUnmute()
|
||||
@@ -432,22 +415,22 @@ let PostDropdownMenuItems = ({
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [_, queueMute, queueUnmute, postAuthor.viewer?.muted])
|
||||
}
|
||||
|
||||
const onShareATURI = useCallback(() => {
|
||||
const onShareATURI = () => {
|
||||
shareText(postUri)
|
||||
}, [postUri])
|
||||
}
|
||||
|
||||
const onShareAuthorDID = useCallback(() => {
|
||||
const onShareAuthorDID = () => {
|
||||
shareText(postAuthor.did)
|
||||
}, [postAuthor.did])
|
||||
}
|
||||
|
||||
const onReportMisclassification = useCallback(() => {
|
||||
const onReportMisclassification = () => {
|
||||
const url = `https://docs.google.com/forms/d/e/1FAIpQLSd0QPqhNFksDQf1YyOos7r1ofCLvmrKAH1lU042TaS3GAZaWQ/viewform?entry.1756031717=${toShareUrl(
|
||||
href,
|
||||
)}`
|
||||
openLink(url)
|
||||
}, [href, openLink])
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {memo, useCallback} from 'react'
|
||||
import React, {memo} from 'react'
|
||||
import {
|
||||
Pressable,
|
||||
type PressableStateCallbackType,
|
||||
@@ -55,6 +55,7 @@ let PostCtrls = ({
|
||||
record,
|
||||
richText,
|
||||
feedContext,
|
||||
reqId,
|
||||
style,
|
||||
onPressReply,
|
||||
onPostReply,
|
||||
@@ -67,6 +68,7 @@ let PostCtrls = ({
|
||||
record: AppBskyFeedPost.Record
|
||||
richText: RichTextAPI
|
||||
feedContext?: string | undefined
|
||||
reqId?: string | undefined
|
||||
style?: StyleProp<ViewStyle>
|
||||
onPressReply: () => void
|
||||
onPostReply?: (postUri: string | undefined) => void
|
||||
@@ -117,7 +119,7 @@ let PostCtrls = ({
|
||||
const [hasLikeIconBeenToggled, setHasLikeIconBeenToggled] =
|
||||
React.useState(false)
|
||||
|
||||
const onPressToggleLike = React.useCallback(async () => {
|
||||
const onPressToggleLike = async () => {
|
||||
if (isBlocked) {
|
||||
Toast.show(
|
||||
_(msg`Cannot interact with a blocked user`),
|
||||
@@ -134,6 +136,7 @@ let PostCtrls = ({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionLike',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
captureAction(ProgressGuideAction.Like)
|
||||
await queueLike()
|
||||
@@ -145,20 +148,9 @@ let PostCtrls = ({
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}, [
|
||||
_,
|
||||
playHaptic,
|
||||
post.uri,
|
||||
post.viewer?.like,
|
||||
queueLike,
|
||||
queueUnlike,
|
||||
sendInteraction,
|
||||
captureAction,
|
||||
feedContext,
|
||||
isBlocked,
|
||||
])
|
||||
}
|
||||
|
||||
const onRepost = useCallback(async () => {
|
||||
const onRepost = async () => {
|
||||
if (isBlocked) {
|
||||
Toast.show(
|
||||
_(msg`Cannot interact with a blocked user`),
|
||||
@@ -173,6 +165,7 @@ let PostCtrls = ({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionRepost',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
await queueRepost()
|
||||
} else {
|
||||
@@ -183,18 +176,9 @@ let PostCtrls = ({
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}, [
|
||||
_,
|
||||
post.uri,
|
||||
post.viewer?.repost,
|
||||
queueRepost,
|
||||
queueUnrepost,
|
||||
sendInteraction,
|
||||
feedContext,
|
||||
isBlocked,
|
||||
])
|
||||
}
|
||||
|
||||
const onQuote = useCallback(() => {
|
||||
const onQuote = () => {
|
||||
if (isBlocked) {
|
||||
Toast.show(
|
||||
_(msg`Cannot interact with a blocked user`),
|
||||
@@ -207,22 +191,15 @@ let PostCtrls = ({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionQuote',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
openComposer({
|
||||
quote: post,
|
||||
onPost: onPostReply,
|
||||
})
|
||||
}, [
|
||||
_,
|
||||
sendInteraction,
|
||||
post,
|
||||
feedContext,
|
||||
openComposer,
|
||||
onPostReply,
|
||||
isBlocked,
|
||||
])
|
||||
}
|
||||
|
||||
const onShare = useCallback(() => {
|
||||
const onShare = () => {
|
||||
const urip = new AtUri(post.uri)
|
||||
const href = makeProfileLink(post.author, 'post', urip.rkey)
|
||||
const url = toShareUrl(href)
|
||||
@@ -231,8 +208,9 @@ let PostCtrls = ({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionShare',
|
||||
feedContext,
|
||||
reqId,
|
||||
})
|
||||
}, [post.uri, post.author, sendInteraction, feedContext])
|
||||
}
|
||||
|
||||
const btnStyle = React.useCallback(
|
||||
({pressed, hovered}: PressableStateCallbackType) => [
|
||||
@@ -374,6 +352,7 @@ let PostCtrls = ({
|
||||
testID="postDropdownBtn"
|
||||
post={post}
|
||||
postFeedContext={feedContext}
|
||||
postReqId={reqId}
|
||||
record={record}
|
||||
richText={richText}
|
||||
style={{padding: 5}}
|
||||
|
||||
Reference in New Issue
Block a user