fix(mobile): active view switch, use is fetching for disable state (#2931)
This commit is contained in:
parent
8b07a9a573
commit
d4ad565a80
|
|
@ -17,7 +17,7 @@ export const EntryListContentArticle = forwardRef<
|
|||
>(({ entryIds, active }, ref) => {
|
||||
const playingAudioUrl = usePlayingUrl()
|
||||
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching, isLoading } = useFetchEntriesControls()
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching } = useFetchEntriesControls()
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ item: id, extraData }: ListRenderItemInfo<string>) => (
|
||||
|
|
@ -32,7 +32,7 @@ export const EntryListContentArticle = forwardRef<
|
|||
)
|
||||
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isLoading,
|
||||
disabled: active === false || isFetching,
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ export const EntryListContentPicture = forwardRef<
|
|||
"data" | "renderItem"
|
||||
>
|
||||
>(({ entryIds, active, ...rest }, ref) => {
|
||||
const { fetchNextPage, refetch, isRefetching, hasNextPage, isLoading } = useFetchEntriesControls()
|
||||
const { fetchNextPage, refetch, isRefetching, hasNextPage, isFetching } =
|
||||
useFetchEntriesControls()
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isLoading,
|
||||
disabled: active === false || isFetching,
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const EntryListContentSocial = forwardRef<
|
|||
ElementRef<typeof TimelineSelectorList>,
|
||||
{ entryIds: string[]; active?: boolean }
|
||||
>(({ entryIds, active }, ref) => {
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching, isLoading } = useFetchEntriesControls()
|
||||
const { fetchNextPage, isFetching, refetch, isRefetching } = 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 || isLoading,
|
||||
disabled: active === false || isFetching,
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ export const EntryListContentVideo = forwardRef<
|
|||
"data" | "renderItem"
|
||||
>
|
||||
>(({ entryIds, active, ...rest }, ref) => {
|
||||
const { fetchNextPage, refetch, isRefetching, isFetching, isLoading } = useFetchEntriesControls()
|
||||
const { fetchNextPage, refetch, isRefetching, isFetching } = useFetchEntriesControls()
|
||||
const { onViewableItemsChanged, onScroll } = useOnViewableItemsChanged({
|
||||
disabled: active === false || isLoading,
|
||||
disabled: active === false || isFetching,
|
||||
})
|
||||
|
||||
const ListFooterComponent = useMemo(
|
||||
|
|
|
|||
|
|
@ -49,17 +49,18 @@ const AnimatedPagerView = Animated.createAnimatedComponent<typeof PagerView>(Pag
|
|||
|
||||
function ViewPagerList({ viewId }: { viewId: FeedViewType }) {
|
||||
const activeViews = useViewWithSubscription()
|
||||
const viewIdIndex = activeViews.findIndex((view) => view.view === viewId)
|
||||
const { page, pagerRef, ...rest } = usePagerView({
|
||||
initialPage: viewId,
|
||||
initialPage: viewIdIndex,
|
||||
onIndexChange: (index) => {
|
||||
selectTimeline({ type: "view", viewId: index })
|
||||
selectTimeline({ type: "view", viewId: activeViews[index]!.view })
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (page === viewId) return
|
||||
pagerRef.current?.setPage(viewId)
|
||||
}, [page, pagerRef, viewId])
|
||||
if (page === viewIdIndex) return
|
||||
pagerRef.current?.setPage(viewIdIndex)
|
||||
}, [page, pagerRef, viewIdIndex])
|
||||
|
||||
return (
|
||||
<AnimatedPagerView
|
||||
|
|
@ -77,8 +78,8 @@ function ViewPagerList({ viewId }: { viewId: FeedViewType }) {
|
|||
>
|
||||
{useMemo(
|
||||
() =>
|
||||
activeViews.map((view) => (
|
||||
<ViewEntryList key={view.view} viewId={view.view} active={page === view.view} />
|
||||
activeViews.map((view, index) => (
|
||||
<ViewEntryList key={view.view} viewId={view.view} active={page === index} />
|
||||
)),
|
||||
[activeViews, page],
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue