fix(mobile): active views in pager, first loading no mark read (#2920)
* fix(mobile): only show active views in pager * fix: disable mark as read when first loading
This commit is contained in:
@@ -17,7 +17,7 @@ export const EntryListContentArticle = forwardRef<
|
||||
>(({ entryIds, active }, ref) => {
|
||||
const playingAudioUrl = usePlayingUrl()
|
||||
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching } = useFetchEntriesControls()
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching, isLoading } = useFetchEntriesControls()
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ item: id, extraData }: ListRenderItemInfo<string>) => (
|
||||
@@ -32,7 +32,7 @@ export const EntryListContentArticle = forwardRef<
|
||||
)
|
||||
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isFetching,
|
||||
disabled: active === false || isLoading,
|
||||
})
|
||||
|
||||
return (
|
||||
|
||||
@@ -18,10 +18,9 @@ export const EntryListContentPicture = forwardRef<
|
||||
"data" | "renderItem"
|
||||
>
|
||||
>(({ entryIds, active, ...rest }, ref) => {
|
||||
const { fetchNextPage, refetch, isRefetching, hasNextPage, isFetching } =
|
||||
useFetchEntriesControls()
|
||||
const { fetchNextPage, refetch, isRefetching, hasNextPage, isLoading } = useFetchEntriesControls()
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isFetching,
|
||||
disabled: active === false || isLoading,
|
||||
})
|
||||
|
||||
return (
|
||||
|
||||
@@ -13,7 +13,7 @@ export const EntryListContentSocial = forwardRef<
|
||||
ElementRef<typeof TimelineSelectorList>,
|
||||
{ entryIds: string[]; active?: boolean }
|
||||
>(({ entryIds, active }, ref) => {
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching } = useFetchEntriesControls()
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching, isLoading } = useFetchEntriesControls()
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ item: id }: ListRenderItemInfo<string>) => <EntrySocialItem key={id} entryId={id} />,
|
||||
@@ -26,7 +26,7 @@ export const EntryListContentSocial = forwardRef<
|
||||
)
|
||||
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isFetching,
|
||||
disabled: active === false || isLoading,
|
||||
})
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,9 +17,9 @@ export const EntryListContentVideo = forwardRef<
|
||||
"data" | "renderItem"
|
||||
>
|
||||
>(({ entryIds, active, ...rest }, ref) => {
|
||||
const { fetchNextPage, refetch, isRefetching, isFetching } = useFetchEntriesControls()
|
||||
const { fetchNextPage, refetch, isRefetching, isFetching, isLoading } = useFetchEntriesControls()
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isFetching,
|
||||
disabled: active === false || isLoading,
|
||||
})
|
||||
|
||||
const ListFooterComponent = useMemo(
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useEffect, useMemo } from "react"
|
||||
import { Animated, StyleSheet } from "react-native"
|
||||
import PagerView from "react-native-pager-view"
|
||||
|
||||
import { views } from "@/src/constants/views"
|
||||
import { selectTimeline, useSelectedFeed, useSelectedView } from "@/src/modules/screen/atoms"
|
||||
import {
|
||||
useEntryIdsByCategory,
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
useEntryIdsByView,
|
||||
} from "@/src/store/entry/hooks"
|
||||
import { useListEntryIds } from "@/src/store/list/hooks"
|
||||
import { useViewWithSubscription } from "@/src/store/subscription/hooks"
|
||||
|
||||
import { TimelineSelectorProvider } from "../screen/TimelineSelectorProvider"
|
||||
import { EntryListSelector } from "./EntryListSelector"
|
||||
@@ -48,6 +48,7 @@ export function EntryList() {
|
||||
const AnimatedPagerView = Animated.createAnimatedComponent<typeof PagerView>(PagerView)
|
||||
|
||||
function ViewPagerList({ viewId }: { viewId: FeedViewType }) {
|
||||
const activeViews = useViewWithSubscription()
|
||||
const { page, pagerRef, ...rest } = usePagerView({
|
||||
initialPage: viewId,
|
||||
onIndexChange: (index) => {
|
||||
@@ -76,10 +77,10 @@ function ViewPagerList({ viewId }: { viewId: FeedViewType }) {
|
||||
>
|
||||
{useMemo(
|
||||
() =>
|
||||
views.map((view) => (
|
||||
activeViews.map((view) => (
|
||||
<ViewEntryList key={view.view} viewId={view.view} active={page === view.view} />
|
||||
)),
|
||||
[page],
|
||||
[activeViews, page],
|
||||
)}
|
||||
</AnimatedPagerView>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user