// @flow import * as PAGES from 'constants/pages'; import * as ICONS from 'constants/icons'; import React from 'react'; import { withRouter } from 'react-router'; import Button from 'component/button'; import Tag from 'component/tag'; import StickyBox from 'react-sticky-box/dist/esnext'; import Spinner from 'component/spinner'; import usePersistedState from 'effects/use-persisted-state'; // @if TARGET='web' import Ads from 'lbrytv/component/ads'; // @endif const SHOW_CHANNELS = 'SHOW_CHANNELS'; const SHOW_TAGS = 'SHOW_TAGS'; type Props = { subscriptions: Array, followedTags: Array, email: ?string, obscureSideNavigation: boolean, uploadCount: number, sticky: boolean, expanded: boolean, doSignOut: () => void, location: { pathname: string }, }; function SideNavigation(props: Props) { const { subscriptions, followedTags, obscureSideNavigation, uploadCount, doSignOut, email, sticky = true, expanded = false, location, } = props; const { pathname } = location; const isAuthenticated = Boolean(email); const [sideInformation, setSideInformation] = usePersistedState( 'side-navigation:information', getSideInformation(pathname) ); function getSideInformation(path) { switch (path) { case `/$/${PAGES.CHANNELS_FOLLOWING}`: return SHOW_CHANNELS; case `/$/${PAGES.TAGS_FOLLOWING}`: return SHOW_TAGS; case `/$/${PAGES.DISCOVER}`: return null; default: return sideInformation; } } React.useEffect(() => { const sideInfo = getSideInformation(pathname); setSideInformation(sideInfo); }, [pathname, setSideInformation]); function buildLink(path, label, icon, onClick) { return { navigate: path ? `$/${path}` : '/', label, icon, onClick, }; } const Wrapper = ({ children }: any) => sticky ? ( {children} ) : (
{children}
); // @if TARGET='web' if (obscureSideNavigation) { return ; } // @endif return ( ); } export default withRouter(SideNavigation);