Remove getProfile
calls when loading feed (#3881)
* remove unnecessary `getProfile()` calls from feed load add comments ensure only if first simplify nit handle cases where the parent is removed add a comment remove unnecessary `getProfile()` calls from feed load limit only to the first post in the returned items move the logic out of the render and into the query add the grandparent properly update `FeedItem` bump package update `FeedItem` update `post-feed` query update `FeedSlice` * nit * simplify logic * always pass `parentAuthor` * oops! * update `DebugMod`
This commit is contained in:
parent
6d647551cd
commit
70f190d44f
4 changed files with 78 additions and 56 deletions
|
@ -1,6 +1,7 @@
|
|||
import React, {useCallback, useEffect, useRef} from 'react'
|
||||
import {AppState} from 'react-native'
|
||||
import {
|
||||
AppBskyActorDefs,
|
||||
AppBskyFeedDefs,
|
||||
AppBskyFeedPost,
|
||||
AtUri,
|
||||
|
@ -72,6 +73,7 @@ export interface FeedPostSliceItem {
|
|||
reason?: AppBskyFeedDefs.ReasonRepost | ReasonFeedSource
|
||||
feedContext: string | undefined
|
||||
moderation: ModerationDecision
|
||||
parentAuthor?: AppBskyActorDefs.ProfileViewBasic
|
||||
}
|
||||
|
||||
export interface FeedPostSlice {
|
||||
|
@ -302,6 +304,10 @@ export function usePostFeedQuery(
|
|||
AppBskyFeedPost.validateRecord(item.post.record)
|
||||
.success
|
||||
) {
|
||||
const parentAuthor =
|
||||
item.reply?.parent?.author ??
|
||||
slice.items[i + 1]?.reply?.grandparentAuthor
|
||||
|
||||
return {
|
||||
_reactKey: `${slice._reactKey}-${i}-${item.post.uri}`,
|
||||
uri: item.post.uri,
|
||||
|
@ -313,6 +319,7 @@ export function usePostFeedQuery(
|
|||
: item.reason,
|
||||
feedContext: item.feedContext || slice.feedContext,
|
||||
moderation: moderations[i],
|
||||
parentAuthor,
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue