Add hasPinnedCustomFeedOrList to usePinnedFeedsInfos hook
parent
9fb2c29c67
commit
ed391c346d
|
@ -246,13 +246,20 @@ const FOLLOWING_FEED_STUB: FeedSourceInfo = {
|
||||||
likeUri: '',
|
likeUri: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePinnedFeedsInfos(): FeedSourceInfo[] {
|
export function usePinnedFeedsInfos(): {
|
||||||
|
feeds: FeedSourceInfo[]
|
||||||
|
hasPinnedCustomFeedOrList: boolean
|
||||||
|
} {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const [tabs, setTabs] = React.useState<FeedSourceInfo[]>([
|
const [tabs, setTabs] = React.useState<FeedSourceInfo[]>([
|
||||||
FOLLOWING_FEED_STUB,
|
FOLLOWING_FEED_STUB,
|
||||||
])
|
])
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
|
const hasPinnedCustomFeedOrList = React.useMemo<boolean>(() => {
|
||||||
|
return tabs.some(tab => tab !== FOLLOWING_FEED_STUB)
|
||||||
|
}, [tabs])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!preferences?.feeds?.pinned) return
|
if (!preferences?.feeds?.pinned) return
|
||||||
const uris = preferences.feeds.pinned
|
const uris = preferences.feeds.pinned
|
||||||
|
@ -300,5 +307,5 @@ export function usePinnedFeedsInfos(): FeedSourceInfo[] {
|
||||||
fetchFeedInfo()
|
fetchFeedInfo()
|
||||||
}, [queryClient, setTabs, preferences?.feeds?.pinned])
|
}, [queryClient, setTabs, preferences?.feeds?.pinned])
|
||||||
|
|
||||||
return tabs
|
return {feeds: tabs, hasPinnedCustomFeedOrList}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ function FeedsTabBarPublic() {
|
||||||
function FeedsTabBarTablet(
|
function FeedsTabBarTablet(
|
||||||
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
||||||
) {
|
) {
|
||||||
const feeds = usePinnedFeedsInfos()
|
const {feeds} = usePinnedFeedsInfos()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const {headerMinimalShellTransform} = useMinimalShellMode()
|
const {headerMinimalShellTransform} = useMinimalShellMode()
|
||||||
|
|
|
@ -26,7 +26,7 @@ export function FeedsTabBar(
|
||||||
const {isSandbox, hasSession} = useSession()
|
const {isSandbox, hasSession} = useSession()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const setDrawerOpen = useSetDrawerOpen()
|
const setDrawerOpen = useSetDrawerOpen()
|
||||||
const feeds = usePinnedFeedsInfos()
|
const {feeds} = usePinnedFeedsInfos()
|
||||||
const brandBlue = useColorSchemeStyle(s.brandBlue, s.blue3)
|
const brandBlue = useColorSchemeStyle(s.brandBlue, s.blue3)
|
||||||
const {headerHeight} = useShellLayout()
|
const {headerHeight} = useShellLayout()
|
||||||
const {headerMinimalShellTransform} = useMinimalShellMode()
|
const {headerMinimalShellTransform} = useMinimalShellMode()
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {usePinnedFeedsInfos} from '#/state/queries/feed'
|
||||||
export function DesktopFeeds() {
|
export function DesktopFeeds() {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const feeds = usePinnedFeedsInfos()
|
const {feeds} = usePinnedFeedsInfos()
|
||||||
|
|
||||||
const route = useNavigationState(state => {
|
const route = useNavigationState(state => {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
|
|
Loading…
Reference in New Issue