// @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'; import classnames from 'classnames'; import { PINNED_LABEL_1, PINNED_URI_1, PINNED_URI_2, PINNED_LABEL_2 } from 'config'; // @if TARGET='web' // import Ads from 'web/component/ads'; // @endif const SHOW_CHANNELS = 'SHOW_CHANNELS'; const SHOW_TAGS = 'SHOW_TAGS'; type Props = { subscriptions: Array, followedTags: Array, email: ?string, uploadCount: number, sticky: boolean, expanded: boolean, doSignOut: () => void, location: { pathname: string }, purchaseSuccess: boolean, doClearPurchasedUriSuccess: () => void, }; function SideNavigation(props: Props) { const { subscriptions, followedTags, uploadCount, doSignOut, email, sticky = true, expanded = false, location, purchaseSuccess, doClearPurchasedUriSuccess, } = props; const { pathname } = location; const isAuthenticated = Boolean(email); const [pulseLibrary, setPulseLibrary] = React.useState(false); const [sideInformation, setSideInformation] = usePersistedState( 'side-navigation:information', getSideInformation(pathname) ); const isPersonalized = !IS_WEB || isAuthenticated; const requireAuthOnPersonalizedActions = IS_WEB; function getSideInformation(path) { switch (path) { case `/$/${PAGES.CHANNELS_FOLLOWING}`: return SHOW_CHANNELS; case `/$/${PAGES.TAGS_FOLLOWING}`: return SHOW_TAGS; default: return sideInformation; } } React.useEffect(() => { const sideInfo = getSideInformation(pathname); setSideInformation(sideInfo); }, [pathname, setSideInformation]); React.useEffect(() => { if (purchaseSuccess) { setPulseLibrary(true); let timeout = setTimeout(() => { setPulseLibrary(false); doClearPurchasedUriSuccess(); }, 2500); return () => clearTimeout(timeout); } }, [setPulseLibrary, purchaseSuccess, doClearPurchasedUriSuccess]); function buildLink(path, label, icon, onClick, requiresAuth = false, isLiteral = false) { return { navigate: !isLiteral ? `$/${path}` : `${path}`, label, icon, onClick, requiresAuth, }; } const Wrapper = ({ children }: any) => sticky ? ( {children} ) : (
{children}
); return ( // @if TARGET='web' {/* {!isAuthenticated && !expanded && } commenting out sidebar ads for test */} // @endif ); } export default withRouter(SideNavigation);