diff options
author | Cooper Edmunds <cooper6789@gmail.com> | 2023-11-29 14:23:19 -0500 |
---|---|---|
committer | Cooper Edmunds <cooper6789@gmail.com> | 2023-11-29 14:23:19 -0500 |
commit | ed391c346d6e6858d0d24c08def2974df8ccbde7 (patch) | |
tree | 58124c26e41691cbd91efb26f5f0249fe615f480 /src | |
parent | 9fb2c29c672f6be07410ae1ca4d7e47b6c98f914 (diff) | |
download | voidsky-ed391c346d6e6858d0d24c08def2974df8ccbde7.tar.zst |
Add hasPinnedCustomFeedOrList to usePinnedFeedsInfos hook
Diffstat (limited to 'src')
-rw-r--r-- | src/state/queries/feed.ts | 11 | ||||
-rw-r--r-- | src/view/com/pager/FeedsTabBar.web.tsx | 2 | ||||
-rw-r--r-- | src/view/com/pager/FeedsTabBarMobile.tsx | 2 | ||||
-rw-r--r-- | src/view/shell/desktop/Feeds.tsx | 2 |
4 files changed, 12 insertions, 5 deletions
diff --git a/src/state/queries/feed.ts b/src/state/queries/feed.ts index b5d491a5c..3266b0f6b 100644 --- a/src/state/queries/feed.ts +++ b/src/state/queries/feed.ts @@ -246,13 +246,20 @@ const FOLLOWING_FEED_STUB: FeedSourceInfo = { likeUri: '', } -export function usePinnedFeedsInfos(): FeedSourceInfo[] { +export function usePinnedFeedsInfos(): { + feeds: FeedSourceInfo[] + hasPinnedCustomFeedOrList: boolean +} { const queryClient = useQueryClient() const [tabs, setTabs] = React.useState<FeedSourceInfo[]>([ FOLLOWING_FEED_STUB, ]) const {data: preferences} = usePreferencesQuery() + const hasPinnedCustomFeedOrList = React.useMemo<boolean>(() => { + return tabs.some(tab => tab !== FOLLOWING_FEED_STUB) + }, [tabs]) + React.useEffect(() => { if (!preferences?.feeds?.pinned) return const uris = preferences.feeds.pinned @@ -300,5 +307,5 @@ export function usePinnedFeedsInfos(): FeedSourceInfo[] { fetchFeedInfo() }, [queryClient, setTabs, preferences?.feeds?.pinned]) - return tabs + return {feeds: tabs, hasPinnedCustomFeedOrList} } diff --git a/src/view/com/pager/FeedsTabBar.web.tsx b/src/view/com/pager/FeedsTabBar.web.tsx index fdb4df171..5ec6c68c3 100644 --- a/src/view/com/pager/FeedsTabBar.web.tsx +++ b/src/view/com/pager/FeedsTabBar.web.tsx @@ -79,7 +79,7 @@ function FeedsTabBarPublic() { function FeedsTabBarTablet( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, ) { - const feeds = usePinnedFeedsInfos() + const {feeds} = usePinnedFeedsInfos() const pal = usePalette('default') const {hasSession} = useSession() const {headerMinimalShellTransform} = useMinimalShellMode() diff --git a/src/view/com/pager/FeedsTabBarMobile.tsx b/src/view/com/pager/FeedsTabBarMobile.tsx index 735aa1bac..46cb488d5 100644 --- a/src/view/com/pager/FeedsTabBarMobile.tsx +++ b/src/view/com/pager/FeedsTabBarMobile.tsx @@ -26,7 +26,7 @@ export function FeedsTabBar( const {isSandbox, hasSession} = useSession() const {_} = useLingui() const setDrawerOpen = useSetDrawerOpen() - const feeds = usePinnedFeedsInfos() + const {feeds} = usePinnedFeedsInfos() const brandBlue = useColorSchemeStyle(s.brandBlue, s.blue3) const {headerHeight} = useShellLayout() const {headerMinimalShellTransform} = useMinimalShellMode() diff --git a/src/view/shell/desktop/Feeds.tsx b/src/view/shell/desktop/Feeds.tsx index eeeca4fd8..ff51ffe22 100644 --- a/src/view/shell/desktop/Feeds.tsx +++ b/src/view/shell/desktop/Feeds.tsx @@ -11,7 +11,7 @@ import {usePinnedFeedsInfos} from '#/state/queries/feed' export function DesktopFeeds() { const pal = usePalette('default') const {_} = useLingui() - const feeds = usePinnedFeedsInfos() + const {feeds} = usePinnedFeedsInfos() const route = useNavigationState(state => { if (!state) { |