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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user