From 12ce75e44eb7d93fc343e0eb1fb6b5aedf0ddf57 Mon Sep 17 00:00:00 2001
From: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Date: Thu, 11 Sep 2025 10:25:14 +0800
Subject: [PATCH] fix(mobile): exclude all view type
---
.../src/modules/screen/PagerList.ios.tsx | 2 +-
apps/mobile/src/modules/screen/PagerList.tsx | 2 +-
.../modules/screen/TimelineViewSelector.tsx | 33 +++++++++----------
apps/mobile/src/modules/screen/atoms.ts | 2 +-
.../store/src/modules/subscription/hooks.ts | 6 +++-
5 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/apps/mobile/src/modules/screen/PagerList.ios.tsx b/apps/mobile/src/modules/screen/PagerList.ios.tsx
index 7585dd19d..3f4b43cc5 100644
--- a/apps/mobile/src/modules/screen/PagerList.ios.tsx
+++ b/apps/mobile/src/modules/screen/PagerList.ios.tsx
@@ -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],
diff --git a/apps/mobile/src/modules/screen/PagerList.tsx b/apps/mobile/src/modules/screen/PagerList.tsx
index 9d2fb3fc5..4ab680d1a 100644
--- a/apps/mobile/src/modules/screen/PagerList.tsx
+++ b/apps/mobile/src/modules/screen/PagerList.tsx
@@ -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),
diff --git a/apps/mobile/src/modules/screen/TimelineViewSelector.tsx b/apps/mobile/src/modules/screen/TimelineViewSelector.tsx
index 49950e8f8..48968709e 100644
--- a/apps/mobile/src/modules/screen/TimelineViewSelector.tsx
+++ b/apps/mobile/src/modules/screen/TimelineViewSelector.tsx
@@ -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(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 (
-
- )
- })}
+ {activeViews.map((v, index) => {
+ const view = views.find((view) => view.view === v)
+ if (!view) return null
+ return (
+
+ )
+ })}
)
@@ -80,7 +77,7 @@ function ItemWrapper({
style?: Exclude, 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,
diff --git a/apps/mobile/src/modules/screen/atoms.ts b/apps/mobile/src/modules/screen/atoms.ts
index b381b0391..a59402eda 100644
--- a/apps/mobile/src/modules/screen/atoms.ts
+++ b/apps/mobile/src/modules/screen/atoms.ts
@@ -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),
diff --git a/packages/internal/store/src/modules/subscription/hooks.ts b/packages/internal/store/src/modules/subscription/hooks.ts
index 95e0cf4bf..6b810cfc6 100644
--- a/packages/internal/store/src/modules/subscription/hooks.ts
+++ b/packages/internal/store/src/modules/subscription/hooks.ts
@@ -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 ||