Refactor for clarity
This commit is contained in:
@@ -350,25 +350,28 @@ let PostFeed = ({
|
|||||||
let sliceIndex = -1
|
let sliceIndex = -1
|
||||||
|
|
||||||
if (isVideoFeedAndIsEnabled) {
|
if (isVideoFeedAndIsEnabled) {
|
||||||
const rows: {
|
const videos: {
|
||||||
item: FeedPostSliceItem
|
item: FeedPostSliceItem
|
||||||
feedContext: string | undefined
|
feedContext: string | undefined
|
||||||
}[][] = []
|
}[] = []
|
||||||
let slices: {slice: FeedPostSlice; root: FeedPostSliceItem}[] = []
|
|
||||||
for (const page of data.pages) {
|
for (const page of data.pages) {
|
||||||
for (const slice of page.slices) {
|
for (const slice of page.slices) {
|
||||||
const root = slice.items.at(0)
|
const item = slice.items.at(0)
|
||||||
if (root && AppBskyEmbedVideo.isView(root.post.embed)) {
|
if (item && AppBskyEmbedVideo.isView(item.post.embed)) {
|
||||||
slices.push({slice, root})
|
videos.push({item, feedContext: slice.feedContext})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < slices.length; i++) {
|
const rows: {
|
||||||
const slice = slices[i]
|
item: FeedPostSliceItem
|
||||||
const root = slice.root
|
feedContext: string | undefined
|
||||||
|
}[][] = []
|
||||||
|
for (let i = 0; i < videos.length; i++) {
|
||||||
|
const video = videos[i]
|
||||||
|
const item = video.item
|
||||||
const cols = gtMobile ? 3 : 2
|
const cols = gtMobile ? 3 : 2
|
||||||
const rowItem = {item: root, feedContext: slice.slice.feedContext}
|
const rowItem = {item, feedContext: video.feedContext}
|
||||||
if (i % cols === 0) {
|
if (i % cols === 0) {
|
||||||
rows.push([rowItem])
|
rows.push([rowItem])
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user