fix feedback for new video grid
This commit is contained in:
@@ -106,14 +106,17 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
|
|||||||
if (slice === null) {
|
if (slice === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (const postItem of slice.items) {
|
for (const [i, postItem] of slice.items.entries()) {
|
||||||
if (!history.current.has(postItem)) {
|
if (!history.current.has(postItem)) {
|
||||||
history.current.add(postItem)
|
history.current.add(postItem)
|
||||||
queue.current.add(
|
queue.current.add(
|
||||||
toString({
|
toString({
|
||||||
item: postItem.uri,
|
item: postItem.uri,
|
||||||
event: 'app.bsky.feed.defs#interactionSeen',
|
event: 'app.bsky.feed.defs#interactionSeen',
|
||||||
feedContext: slice.feedContext,
|
feedContext:
|
||||||
|
slice.type === 'videoGridRow'
|
||||||
|
? slice.feedContexts?.[i]
|
||||||
|
: slice.feedContext,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
sendToFeed()
|
sendToFeed()
|
||||||
|
|||||||
@@ -98,8 +98,9 @@ type FeedRow =
|
|||||||
| {
|
| {
|
||||||
type: 'videoGridRow'
|
type: 'videoGridRow'
|
||||||
key: string
|
key: string
|
||||||
slices: FeedPostSliceItem[]
|
items: FeedPostSliceItem[]
|
||||||
sourceFeedUri: string
|
sourceFeedUri: string
|
||||||
|
feedContexts: (string | undefined)[]
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'sliceViewFullThread'
|
type: 'sliceViewFullThread'
|
||||||
@@ -123,9 +124,16 @@ type FeedRow =
|
|||||||
key: string
|
key: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFeedPostSlice(feedRow: FeedRow): FeedPostSlice | null {
|
export function getFeedPostSlice(feedRow: FeedRow): {
|
||||||
|
items: FeedPostSliceItem[]
|
||||||
|
type: 'sliceItem' | 'videoGridRow'
|
||||||
|
feedContext?: string | undefined
|
||||||
|
feedContexts?: (string | undefined)[]
|
||||||
|
} | null {
|
||||||
if (feedRow.type === 'sliceItem') {
|
if (feedRow.type === 'sliceItem') {
|
||||||
return feedRow.slice
|
return {...feedRow.slice, type: 'sliceItem'}
|
||||||
|
} else if (feedRow.type === 'videoGridRow') {
|
||||||
|
return feedRow
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -337,7 +345,10 @@ let PostFeed = ({
|
|||||||
let sliceIndex = -1
|
let sliceIndex = -1
|
||||||
|
|
||||||
if (isVideoFeedAndIsEnabled) {
|
if (isVideoFeedAndIsEnabled) {
|
||||||
const rows: FeedPostSliceItem[][] = []
|
const rows: {
|
||||||
|
item: FeedPostSliceItem
|
||||||
|
feedContext: string | undefined
|
||||||
|
}[][] = []
|
||||||
let slices: {slice: FeedPostSlice; index: number}[] = []
|
let slices: {slice: FeedPostSlice; index: number}[] = []
|
||||||
for (const page of data.pages) {
|
for (const page of data.pages) {
|
||||||
for (const slice of page.slices) {
|
for (const slice of page.slices) {
|
||||||
@@ -355,10 +366,11 @@ let PostFeed = ({
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const cols = gtMobile ? 3 : 2
|
const cols = gtMobile ? 3 : 2
|
||||||
|
const rowItem = {item: root, feedContext: slice.slice.feedContext}
|
||||||
if (i % cols === 0) {
|
if (i % cols === 0) {
|
||||||
rows.push([root])
|
rows.push([rowItem])
|
||||||
} else {
|
} else {
|
||||||
rows[rows.length - 1].push(root)
|
rows[rows.length - 1].push(rowItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,9 +378,10 @@ let PostFeed = ({
|
|||||||
sliceIndex++
|
sliceIndex++
|
||||||
arr.push({
|
arr.push({
|
||||||
type: 'videoGridRow',
|
type: 'videoGridRow',
|
||||||
key: row.map(r => r._reactKey).join('-'),
|
key: row.map(r => r.item._reactKey).join('-'),
|
||||||
slices: row,
|
items: row.map(r => r.item),
|
||||||
sourceFeedUri: feedUri,
|
sourceFeedUri: feedUri,
|
||||||
|
feedContexts: row.map(r => r.feedContext),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -634,7 +647,7 @@ let PostFeed = ({
|
|||||||
} else if (row.type === 'videoGridRow') {
|
} else if (row.type === 'videoGridRow') {
|
||||||
return (
|
return (
|
||||||
<PostFeedVideoGridRow
|
<PostFeedVideoGridRow
|
||||||
slices={row.slices}
|
slices={row.items}
|
||||||
sourceContext={{
|
sourceContext={{
|
||||||
type: 'feedgen',
|
type: 'feedgen',
|
||||||
uri: row.sourceFeedUri,
|
uri: row.sourceFeedUri,
|
||||||
|
|||||||
Reference in New Issue
Block a user