fix(mobile): exclude all view type
This commit is contained in:
@@ -24,7 +24,7 @@ export function PagerList({
|
||||
const selectedFeed = useSelectedFeed()
|
||||
const viewId = selectedFeed?.type === "view" ? selectedFeed.viewId : undefined
|
||||
|
||||
const activeViews = useViewWithSubscription()
|
||||
const activeViews = useViewWithSubscription({ excludeAll: true })
|
||||
const activeViewIndex = useMemo(
|
||||
() => activeViews.indexOf(viewId as FeedViewType),
|
||||
[activeViews, viewId],
|
||||
|
||||
@@ -32,7 +32,7 @@ export function PagerList({
|
||||
const selectedFeed = useSelectedFeed()
|
||||
const viewId = selectedFeed?.type === "view" ? selectedFeed.viewId : undefined
|
||||
|
||||
const activeViews = useViewWithSubscription()
|
||||
const activeViews = useViewWithSubscription({ excludeAll: true })
|
||||
|
||||
const activeViewIndex = useMemo(
|
||||
() => activeViews.indexOf(viewId as FeedViewType),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useViewWithSubscription } from "@follow/store/subscription/hooks"
|
||||
import { useUnreadByView } from "@follow/store/unread/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
@@ -27,7 +26,7 @@ const ACTIVE_WIDTH = 180
|
||||
const INACTIVE_WIDTH = 48
|
||||
const ACTIVE_TEXT_WIDTH = 100
|
||||
export function TimelineViewSelector() {
|
||||
const activeViews = useViewWithSubscription()
|
||||
const activeViews = useViewWithSubscription({ excludeAll: true })
|
||||
const scrollViewRef = React.useRef<ScrollView | null>(null)
|
||||
const selectedFeed = useSelectedFeed()
|
||||
return (
|
||||
@@ -44,21 +43,19 @@ export function TimelineViewSelector() {
|
||||
contentContainerClassName="flex-row gap-3 items-center px-3"
|
||||
showsHorizontalScrollIndicator={false}
|
||||
>
|
||||
{activeViews
|
||||
.filter((v) => v !== FeedViewType.All)
|
||||
.map((v, index) => {
|
||||
const view = views.find((view) => view.view === v)
|
||||
if (!view) return null
|
||||
return (
|
||||
<ViewItem
|
||||
key={view.name}
|
||||
index={index}
|
||||
view={view}
|
||||
scrollViewRef={scrollViewRef}
|
||||
isActive={selectedFeed?.type === "view" && selectedFeed.viewId === view.view}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
{activeViews.map((v, index) => {
|
||||
const view = views.find((view) => view.view === v)
|
||||
if (!view) return null
|
||||
return (
|
||||
<ViewItem
|
||||
key={view.name}
|
||||
index={index}
|
||||
view={view}
|
||||
scrollViewRef={scrollViewRef}
|
||||
isActive={selectedFeed?.type === "view" && selectedFeed.viewId === view.view}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</ScrollView>
|
||||
</View>
|
||||
)
|
||||
@@ -80,7 +77,7 @@ function ItemWrapper({
|
||||
style?: Exclude<StyleProp<ViewStyle>, number>
|
||||
}) {
|
||||
const { width: windowWidth } = useWindowDimensions()
|
||||
const activeViews = useViewWithSubscription()
|
||||
const activeViews = useViewWithSubscription({ excludeAll: true })
|
||||
const dragProgress = useTimelineSelectorDragProgress()
|
||||
const activeWidth = Math.max(
|
||||
windowWidth - (INACTIVE_WIDTH + 12) * (activeViews.length - 1) - 8 * 2,
|
||||
|
||||
@@ -400,7 +400,7 @@ export const TimelineSelectorDragProgressProvider = ({ children }: { children: R
|
||||
const selectedFeed = useSelectedFeed()
|
||||
const viewId = selectedFeed?.type === "view" ? selectedFeed.viewId : undefined
|
||||
|
||||
const activeViews = useViewWithSubscription()
|
||||
const activeViews = useViewWithSubscription({ excludeAll: true })
|
||||
|
||||
const activeViewIndex = useMemo(
|
||||
() => activeViews.indexOf(viewId as FeedViewType),
|
||||
|
||||
@@ -257,10 +257,14 @@ export const getSubscriptionCategory = (view?: FeedViewType) => {
|
||||
return view === undefined ? [] : Array.from(state.categories[view])
|
||||
}
|
||||
|
||||
export const useViewWithSubscription = () =>
|
||||
export const useViewWithSubscription = (options?: { excludeAll?: boolean }) =>
|
||||
useSubscriptionStore((state) => {
|
||||
return views
|
||||
.filter((view) => {
|
||||
if (options?.excludeAll && view.view === FeedViewType.All) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (
|
||||
view.view === FeedViewType.All ||
|
||||
view.view === FeedViewType.Articles ||
|
||||
|
||||
Reference in New Issue
Block a user