Hoist moderation, attempt to fill feed up to 30 (#2134)

* Move moderatePost up to feed query

* Attemt to fill page up to 30

* Add the 'ensure full page' behavior to notifs

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
Eric Bailey 2023-12-07 15:44:22 -06:00 committed by GitHub
parent 940fc0ea5c
commit 174a1622c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 112 additions and 83 deletions

View file

@ -27,7 +27,6 @@ import {
usePostFeedQuery,
pollLatest,
} from '#/state/queries/post-feed'
import {useModerationOpts} from '#/state/queries/preferences'
import {isWeb} from '#/platform/detection'
import {listenPostCreated} from '#/state/events'
import {useSession} from '#/state/session'
@ -82,8 +81,10 @@ let Feed = ({
const [isPTRing, setIsPTRing] = React.useState(false)
const checkForNewRef = React.useRef<(() => void) | null>(null)
const moderationOpts = useModerationOpts()
const opts = React.useMemo(() => ({enabled}), [enabled])
const opts = React.useMemo(
() => ({enabled, ignoreFilterFor}),
[enabled, ignoreFilterFor],
)
const {
data,
isFetching,
@ -144,7 +145,7 @@ let Feed = ({
const feedItems = React.useMemo(() => {
let arr: any[] = []
if (isFetched && moderationOpts) {
if (isFetched) {
if (isError && isEmpty) {
arr = arr.concat([ERROR_ITEM])
}
@ -162,7 +163,7 @@ let Feed = ({
arr.push(LOADING_ITEM)
}
return arr
}, [isFetched, isError, isEmpty, data, moderationOpts])
}, [isFetched, isError, isEmpty, data])
// events
// =
@ -224,24 +225,9 @@ let Feed = ({
} else if (item === LOADING_ITEM) {
return <PostFeedLoadingPlaceholder />
}
return (
<FeedSlice
slice={item}
// we check for this before creating the feedItems array
moderationOpts={moderationOpts!}
ignoreFilterFor={ignoreFilterFor}
/>
)
return <FeedSlice slice={item} />
},
[
feed,
error,
onPressTryAgain,
onPressRetryLoadMore,
renderEmptyState,
moderationOpts,
ignoreFilterFor,
],
[feed, error, onPressTryAgain, onPressRetryLoadMore, renderEmptyState],
)
const shouldRenderEndOfFeed =