Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152import {useEffect, useState} from 'react'import {View} from 'react-native'import {msg} from '@lingui/core/macro'import {useLingui} from '@lingui/react'import {useNavigation} from '@react-navigation/native'
import {useBrand} from '#/lib/community/BrandContext'import {HELP_DESK_URL} from '#/lib/constants'import {useSession} from '#/state/session'import {DesktopFeeds} from '#/view/shell/desktop/Feeds'import {DesktopSearch} from '#/view/shell/desktop/Search'import {SidebarTrendingTopics} from '#/view/shell/desktop/SidebarTrendingTopics'import { atoms as a, useGutters, useLayoutBreakpoints, useTheme, web,} from '#/alf'import {AppLanguageDropdown} from '#/components/AppLanguageDropdown'import {CENTER_COLUMN_OFFSET} from '#/components/Layout'import {InlineLinkText} from '#/components/Link'import {ProgressGuideList} from '#/components/ProgressGuide/List'import {Text} from '#/components/Typography'import {SidebarLiveEventFeedsBanner} from '#/features/liveEvents/components/SidebarLiveEventFeedsBanner'
function useWebQueryParams() { const navigation = useNavigation() const [params, setParams] = useState<Record<string, string>>({})
useEffect(() => { return navigation.addListener('state', e => { try { const {state} = e.data const lastRoute = state.routes[state.routes.length - 1] setParams(lastRoute.params) } catch (err) {} }) }, [navigation, setParams])
return params}
export function DesktopRightNav({routeName}: {routeName: string}) { const t = useTheme() const {_} = useLingui() const brand = useBrand() const {hasSession} = useSession() const gutters = useGutters(['base', 0, 'base', 'wide']) const isSearchScreen = routeName === 'Search' const isMessagesRelatedScreen = routeName.startsWith('Messages') const webqueryParams = useWebQueryParams() const searchQuery = webqueryParams?.q const showExploreScreenDuplicatedContent = !isSearchScreen || (isSearchScreen && !!searchQuery) const {rightNavVisible, centerColumnOffset, leftNavMinimal} = useLayoutBreakpoints()
if (!rightNavVisible || isMessagesRelatedScreen) { return null }
const width = centerColumnOffset ? 250 : 300
return ( <View style={[ gutters, a.gap_lg, a.pr_2xs, web({ position: 'fixed', left: '50%', transform: [ { translateX: 300 + (centerColumnOffset ? CENTER_COLUMN_OFFSET : 0), }, ...a.scrollbar_offset.transform, ], /** * Compensate for the right padding above (2px) to retain intended width. */ width: width + gutters.paddingLeft + 2, maxHeight: '100vh', }), ]}> {!isSearchScreen && <DesktopSearch />}
{hasSession && ( <> <DesktopFeeds /> <ProgressGuideList /> </> )}
{showExploreScreenDuplicatedContent && <SidebarLiveEventFeedsBanner />} {showExploreScreenDuplicatedContent && <SidebarTrendingTopics />}
<Text style={[a.leading_snug, t.atoms.text_contrast_low]}> {brand.web.links.contribute ? ( <> <InlineLinkText to={brand.web.links.contribute} style={[t.atoms.text_contrast_medium]} label={_(msg`Support Us`)}> {_(msg`Support Us`)} </InlineLinkText> {' \u2022 '} </> ) : null} {hasSession && brand.web.links.community ? ( <> <InlineLinkText to={brand.web.links.community} style={[t.atoms.text_contrast_medium]} label={_(msg`Discussion`)}> {_(msg`Discussion`)} </InlineLinkText> {' \u2022 '} </> ) : null} <InlineLinkText to={brand.web.links.privacy} style={[t.atoms.text_contrast_medium]} label={_(msg`Privacy`)}> {_(msg`Privacy`)} </InlineLinkText> {' \u2022 '} <InlineLinkText to={brand.web.links.tos} style={[t.atoms.text_contrast_medium]} label={_(msg`Terms`)}> {_(msg`Terms`)} </InlineLinkText> {' \u2022 '} <InlineLinkText label={_(msg`Help`)} to={HELP_DESK_URL} style={[t.atoms.text_contrast_medium]}> {_(msg`Help`)} </InlineLinkText> </Text>
{!hasSession && leftNavMinimal && ( <View style={[a.w_full, {height: 32}]}> <AppLanguageDropdown /> </View> )} </View> )}