2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2020-08-10 22:47:39 +02:00
|
|
|
import type { Node } from 'react';
|
2019-03-28 17:53:13 +01:00
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import * as ICONS from 'constants/icons';
|
2021-08-31 09:05:42 +02:00
|
|
|
import * as KEYCODES from 'constants/keycodes';
|
2021-11-23 16:21:33 +01:00
|
|
|
import React, { useEffect } from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2020-05-21 17:38:28 +02:00
|
|
|
import classnames from 'classnames';
|
2020-11-10 06:21:04 +01:00
|
|
|
import Icon from 'component/common/icon';
|
2020-08-10 22:47:39 +02:00
|
|
|
import NotificationBubble from 'component/notificationBubble';
|
2020-11-10 06:21:04 +01:00
|
|
|
import I18nMessage from 'component/i18nMessage';
|
2021-06-09 21:20:19 +02:00
|
|
|
import ChannelThumbnail from 'component/channelThumbnail';
|
2021-12-11 15:59:32 +01:00
|
|
|
import { useIsMobile, useIsLargeScreen } from 'effects/use-screensize';
|
2021-07-13 02:14:43 +02:00
|
|
|
import { GetLinksData } from 'util/buildHomepage';
|
2021-11-12 16:59:11 +01:00
|
|
|
import { DOMAIN, ENABLE_UI_NOTIFICATIONS, ENABLE_NO_SOURCE_CLAIMS, CHANNEL_STAKED_LEVEL_LIVESTREAM } from 'config';
|
|
|
|
|
|
|
|
const FOLLOWED_ITEM_INITIAL_LIMIT = 10;
|
|
|
|
|
|
|
|
type SideNavLink = {
|
|
|
|
title: string,
|
|
|
|
link?: string,
|
|
|
|
route?: string,
|
|
|
|
onClick?: () => any,
|
|
|
|
icon: string,
|
|
|
|
extra?: Node,
|
|
|
|
hideForUnauth?: boolean,
|
|
|
|
};
|
2020-01-03 20:11:47 +01:00
|
|
|
|
2021-11-30 16:27:37 +01:00
|
|
|
const GO_LIVE = {
|
|
|
|
title: 'Go Live',
|
|
|
|
link: `/$/${PAGES.LIVESTREAM}`,
|
|
|
|
icon: ICONS.VIDEO,
|
|
|
|
};
|
|
|
|
|
2020-08-21 17:18:47 +02:00
|
|
|
const HOME = {
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Home',
|
|
|
|
link: `/`,
|
2020-08-21 17:18:47 +02:00
|
|
|
icon: ICONS.HOME,
|
2020-12-08 17:42:11 +01:00
|
|
|
onClick: () => {
|
|
|
|
if (window.location.pathname === '/') window.location.reload();
|
|
|
|
},
|
2020-08-21 17:18:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const RECENT_FROM_FOLLOWING = {
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Following --[sidebar button]--',
|
|
|
|
link: `/$/${PAGES.CHANNELS_FOLLOWING}`,
|
2020-08-21 17:18:47 +02:00
|
|
|
icon: ICONS.SUBSCRIBE,
|
|
|
|
};
|
|
|
|
|
2021-11-30 16:27:37 +01:00
|
|
|
const NOTIFICATIONS = {
|
|
|
|
title: 'Notifications',
|
|
|
|
link: `/$/${PAGES.NOTIFICATIONS}`,
|
|
|
|
icon: ICONS.NOTIFICATION,
|
|
|
|
extra: <NotificationBubble inline />,
|
|
|
|
hideForUnauth: true,
|
|
|
|
};
|
|
|
|
|
2021-11-12 16:59:11 +01:00
|
|
|
const PLAYLISTS = {
|
|
|
|
title: 'Lists',
|
|
|
|
link: `/$/${PAGES.LISTS}`,
|
|
|
|
icon: ICONS.STACK,
|
|
|
|
hideForUnauth: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const UNAUTH_LINKS: Array<SideNavLink> = [
|
|
|
|
{
|
|
|
|
title: 'Log In',
|
|
|
|
link: `/$/${PAGES.AUTH_SIGNIN}`,
|
|
|
|
icon: ICONS.SIGN_IN,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sign Up',
|
|
|
|
link: `/$/${PAGES.AUTH}`,
|
|
|
|
icon: ICONS.SIGN_UP,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Settings',
|
|
|
|
link: `/$/${PAGES.SETTINGS}`,
|
|
|
|
icon: ICONS.SETTINGS,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Help',
|
|
|
|
link: `/$/${PAGES.HELP}`,
|
|
|
|
icon: ICONS.HELP,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-11-30 16:27:37 +01:00
|
|
|
const WILD_WEST = {
|
|
|
|
title: 'Wild West',
|
|
|
|
link: `/$/${PAGES.WILD_WEST}`,
|
|
|
|
icon: ICONS.WILD_WEST,
|
|
|
|
};
|
|
|
|
|
2021-11-12 16:59:11 +01:00
|
|
|
// ****************************************************************************
|
|
|
|
// ****************************************************************************
|
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
2019-06-11 20:10:58 +02:00
|
|
|
subscriptions: Array<Subscription>,
|
2020-09-02 04:38:40 +02:00
|
|
|
followedTags: Array<Tag>,
|
2019-08-21 22:54:44 +02:00
|
|
|
email: ?string,
|
2019-10-11 02:37:18 +02:00
|
|
|
uploadCount: number,
|
2019-12-18 06:27:08 +01:00
|
|
|
doSignOut: () => void,
|
2020-08-10 22:47:39 +02:00
|
|
|
sidebarOpen: boolean,
|
2021-03-16 02:42:49 +01:00
|
|
|
setSidebarOpen: (boolean) => void,
|
2020-08-10 22:47:39 +02:00
|
|
|
isMediumScreen: boolean,
|
|
|
|
isOnFilePage: boolean,
|
2021-03-16 02:42:49 +01:00
|
|
|
unseenCount: number,
|
2020-05-21 17:38:28 +02:00
|
|
|
purchaseSuccess: boolean,
|
|
|
|
doClearPurchasedUriSuccess: () => void,
|
2020-08-11 22:32:03 +02:00
|
|
|
user: ?User,
|
2020-11-10 17:07:00 +01:00
|
|
|
homepageData: any,
|
2021-10-29 15:04:43 +02:00
|
|
|
activeChannelStakedLevel: number,
|
2020-11-10 17:07:00 +01:00
|
|
|
};
|
|
|
|
|
2020-01-02 17:30:27 +01:00
|
|
|
function SideNavigation(props: Props) {
|
2019-12-18 06:27:08 +01:00
|
|
|
const {
|
|
|
|
subscriptions,
|
2020-08-20 17:10:29 +02:00
|
|
|
doSignOut,
|
2019-12-18 06:27:08 +01:00
|
|
|
email,
|
2020-05-21 17:38:28 +02:00
|
|
|
purchaseSuccess,
|
|
|
|
doClearPurchasedUriSuccess,
|
2020-08-10 22:47:39 +02:00
|
|
|
sidebarOpen,
|
|
|
|
setSidebarOpen,
|
|
|
|
isMediumScreen,
|
|
|
|
isOnFilePage,
|
2021-03-16 02:42:49 +01:00
|
|
|
unseenCount,
|
2020-11-10 17:07:00 +01:00
|
|
|
homepageData,
|
2020-08-11 22:32:03 +02:00
|
|
|
user,
|
2021-05-31 08:26:45 +02:00
|
|
|
followedTags,
|
2021-10-29 15:04:43 +02:00
|
|
|
activeChannelStakedLevel,
|
2019-12-18 06:27:08 +01:00
|
|
|
} = props;
|
2020-08-20 17:10:29 +02:00
|
|
|
|
2021-12-08 16:14:03 +01:00
|
|
|
const isLargeScreen = useIsLargeScreen();
|
|
|
|
|
|
|
|
const EXTRA_SIDEBAR_LINKS = GetLinksData(homepageData, isLargeScreen).map(({ pinnedUrls, ...theRest }) => theRest);
|
2021-10-02 09:06:13 +02:00
|
|
|
|
2020-11-10 17:07:00 +01:00
|
|
|
const MOBILE_LINKS: Array<SideNavLink> = [
|
2020-08-20 17:10:29 +02:00
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Upload',
|
|
|
|
link: `/$/${PAGES.UPLOAD}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.PUBLISH,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'New Channel',
|
|
|
|
link: `/$/${PAGES.CHANNEL_NEW}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.CHANNEL,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Uploads',
|
|
|
|
link: `/$/${PAGES.UPLOADS}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.PUBLISH,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Channels',
|
|
|
|
link: `/$/${PAGES.CHANNELS}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.CHANNEL,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Creator Analytics',
|
|
|
|
link: `/$/${PAGES.CREATOR_DASHBOARD}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.ANALYTICS,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Wallet',
|
|
|
|
link: `/$/${PAGES.WALLET}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.WALLET,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
2020-11-10 16:35:55 +01:00
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Rewards',
|
2020-11-10 18:21:31 +01:00
|
|
|
link: `/$/${PAGES.REWARDS}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.REWARDS,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Invites',
|
|
|
|
link: `/$/${PAGES.INVITE}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.INVITE,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Settings',
|
|
|
|
link: `/$/${PAGES.SETTINGS}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.SETTINGS,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Help',
|
|
|
|
link: `/$/${PAGES.HELP}`,
|
2020-08-20 17:10:29 +02:00
|
|
|
icon: ICONS.HELP,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 17:07:00 +01:00
|
|
|
title: 'Sign Out',
|
2020-08-20 17:10:29 +02:00
|
|
|
onClick: doSignOut,
|
|
|
|
icon: ICONS.SIGN_OUT,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-07-07 20:21:11 +02:00
|
|
|
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
2019-12-18 06:27:08 +01:00
|
|
|
const isAuthenticated = Boolean(email);
|
2021-11-12 16:59:11 +01:00
|
|
|
|
2021-10-29 15:04:43 +02:00
|
|
|
const livestreamEnabled = Boolean(
|
|
|
|
ENABLE_NO_SOURCE_CLAIMS &&
|
|
|
|
user &&
|
|
|
|
!user.odysee_live_disabled &&
|
|
|
|
(activeChannelStakedLevel >= CHANNEL_STAKED_LEVEL_LIVESTREAM || user.odysee_live_enabled)
|
|
|
|
);
|
|
|
|
|
2020-05-21 17:38:28 +02:00
|
|
|
const [pulseLibrary, setPulseLibrary] = React.useState(false);
|
2021-11-12 16:59:11 +01:00
|
|
|
const [expandSubscriptions, setExpandSubscriptions] = React.useState(false);
|
|
|
|
const [expandTags, setExpandTags] = React.useState(false);
|
|
|
|
|
2020-04-02 19:02:12 +02:00
|
|
|
const isPersonalized = !IS_WEB || isAuthenticated;
|
2020-08-10 22:47:39 +02:00
|
|
|
const isAbsolute = isOnFilePage || isMediumScreen;
|
2021-12-11 15:59:32 +01:00
|
|
|
const isMobile = useIsMobile();
|
2020-11-10 16:35:55 +01:00
|
|
|
|
2021-12-11 15:59:32 +01:00
|
|
|
const menuCanCloseCompletey = livestreamEnabled || isOnFilePage || isMobile;
|
|
|
|
const hideMenuFromView = menuCanCloseCompletey && !sidebarOpen;
|
|
|
|
|
|
|
|
const [canDisposeMenu, setCanDisposeMenu] = React.useState(false);
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (hideMenuFromView) {
|
|
|
|
const handler = setTimeout(() => {
|
|
|
|
setCanDisposeMenu(true);
|
|
|
|
}, 250);
|
|
|
|
return () => {
|
|
|
|
clearTimeout(handler);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
setCanDisposeMenu(false);
|
|
|
|
}
|
|
|
|
}, [hideMenuFromView]);
|
|
|
|
|
|
|
|
const shouldRenderLargeMenuPushorAbsolute = menuCanCloseCompletey || sidebarOpen;
|
|
|
|
|
|
|
|
const showMicroMenu = !sidebarOpen && !menuCanCloseCompletey;
|
|
|
|
const showPushMenu = sidebarOpen && !menuCanCloseCompletey;
|
|
|
|
|
|
|
|
const showSubscriptionSection =
|
|
|
|
shouldRenderLargeMenuPushorAbsolute && isPersonalized && subscriptions && subscriptions.length > 0;
|
2021-11-12 16:59:11 +01:00
|
|
|
const showTagSection = sidebarOpen && isPersonalized && followedTags && followedTags.length;
|
|
|
|
|
|
|
|
let displayedSubscriptions = subscriptions;
|
|
|
|
if (showSubscriptionSection && subscriptions.length > FOLLOWED_ITEM_INITIAL_LIMIT && !expandSubscriptions) {
|
|
|
|
displayedSubscriptions = subscriptions.slice(0, FOLLOWED_ITEM_INITIAL_LIMIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
let displayedFollowedTags = followedTags;
|
|
|
|
if (showTagSection && followedTags.length > FOLLOWED_ITEM_INITIAL_LIMIT && !expandTags) {
|
|
|
|
displayedFollowedTags = followedTags.slice(0, FOLLOWED_ITEM_INITIAL_LIMIT);
|
|
|
|
}
|
|
|
|
|
2021-11-30 16:27:37 +01:00
|
|
|
function getLink(props: SideNavLink) {
|
|
|
|
const { hideForUnauth, route, link, ...passedProps } = props;
|
|
|
|
const { title, icon, extra } = passedProps;
|
|
|
|
|
|
|
|
if (hideForUnauth && !email) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<li key={route || link || title}>
|
|
|
|
<Button
|
|
|
|
{...passedProps}
|
|
|
|
icon={icon}
|
|
|
|
navigate={route || link}
|
|
|
|
label={__(title)}
|
|
|
|
title={__(title)}
|
|
|
|
className={classnames('navigation-link', {
|
|
|
|
'navigation-link--pulse': icon === ICONS.LIBRARY && pulseLibrary,
|
|
|
|
'navigation-link--highlighted': icon === ICONS.NOTIFICATION && unseenCount > 0,
|
|
|
|
})}
|
|
|
|
activeClass="navigation-link--active"
|
|
|
|
/>
|
|
|
|
{extra && extra}
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-12 16:59:11 +01:00
|
|
|
function getSubscriptionSection() {
|
|
|
|
if (showSubscriptionSection) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<ul className="navigation__secondary navigation-links">
|
|
|
|
{displayedSubscriptions.map((subscription) => (
|
|
|
|
<SubscriptionListItem key={subscription.uri} subscription={subscription} />
|
|
|
|
))}
|
2021-11-30 16:27:37 +01:00
|
|
|
{subscriptions.length > FOLLOWED_ITEM_INITIAL_LIMIT && (
|
|
|
|
<Button
|
|
|
|
key="showMore"
|
|
|
|
label={expandSubscriptions ? __('Show less') : __('Show more')}
|
|
|
|
className="navigation-link"
|
|
|
|
onClick={() => setExpandSubscriptions(!expandSubscriptions)}
|
|
|
|
/>
|
|
|
|
)}
|
2021-11-12 16:59:11 +01:00
|
|
|
</ul>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFollowedTagsSection() {
|
|
|
|
if (showTagSection) {
|
|
|
|
return (
|
|
|
|
<>
|
2021-11-30 16:27:37 +01:00
|
|
|
<ul className="navigation__secondary navigation-links">
|
2021-11-12 16:59:11 +01:00
|
|
|
{displayedFollowedTags.map(({ name }, key) => (
|
|
|
|
<li key={name} className="navigation-link__wrapper">
|
|
|
|
<Button navigate={`/$/discover?t=${name}`} label={`#${name}`} className="navigation-link" />
|
|
|
|
</li>
|
|
|
|
))}
|
2021-11-30 16:27:37 +01:00
|
|
|
{followedTags.length > FOLLOWED_ITEM_INITIAL_LIMIT && (
|
|
|
|
<Button
|
|
|
|
key="showMore"
|
|
|
|
label={expandTags ? __('Show less') : __('Show more')}
|
|
|
|
className="navigation-link"
|
|
|
|
onClick={() => setExpandTags(!expandTags)}
|
|
|
|
/>
|
|
|
|
)}
|
2021-11-12 16:59:11 +01:00
|
|
|
</ul>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-05-21 17:38:28 +02:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (purchaseSuccess) {
|
|
|
|
setPulseLibrary(true);
|
|
|
|
|
|
|
|
let timeout = setTimeout(() => {
|
|
|
|
setPulseLibrary(false);
|
|
|
|
doClearPurchasedUriSuccess();
|
|
|
|
}, 2500);
|
|
|
|
|
|
|
|
return () => clearTimeout(timeout);
|
|
|
|
}
|
|
|
|
}, [setPulseLibrary, purchaseSuccess, doClearPurchasedUriSuccess]);
|
|
|
|
|
2020-08-10 22:47:39 +02:00
|
|
|
React.useEffect(() => {
|
|
|
|
function handleKeydown(e: SyntheticKeyboardEvent<*>) {
|
2021-08-31 09:05:42 +02:00
|
|
|
if (e.keyCode === KEYCODES.ESCAPE && isAbsolute) {
|
2020-08-10 22:47:39 +02:00
|
|
|
setSidebarOpen(false);
|
2021-08-31 09:05:42 +02:00
|
|
|
} else if (e.keyCode === KEYCODES.BACKSLASH) {
|
2021-07-13 01:54:32 +02:00
|
|
|
const hasActiveInput = document.querySelector('input:focus, textarea:focus');
|
2020-08-10 22:47:39 +02:00
|
|
|
if (!hasActiveInput) {
|
|
|
|
setSidebarOpen(!sidebarOpen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleKeydown);
|
|
|
|
|
|
|
|
return () => window.removeEventListener('keydown', handleKeydown);
|
|
|
|
}, [sidebarOpen, setSidebarOpen, isAbsolute]);
|
2019-04-19 23:15:41 +02:00
|
|
|
|
2021-11-23 16:21:33 +01:00
|
|
|
useEffect(() => {
|
2021-12-13 18:21:44 +01:00
|
|
|
if (!window.Optanon) {
|
2021-12-13 21:23:31 +01:00
|
|
|
const gdprDiv = document.getElementById('gdprSidebarLink');
|
2021-11-23 16:21:33 +01:00
|
|
|
if (gdprDiv) {
|
|
|
|
gdprDiv.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [sidebarOpen]);
|
|
|
|
|
2021-03-19 23:34:42 +01:00
|
|
|
const unAuthNudge =
|
|
|
|
DOMAIN === 'lbry.tv' ? null : (
|
|
|
|
<div className="navigation__auth-nudge">
|
|
|
|
<span>
|
|
|
|
<I18nMessage tokens={{ lbc: <Icon icon={ICONS.LBC} /> }}>
|
|
|
|
Sign up to earn %lbc% for you and your favorite creators.
|
|
|
|
</I18nMessage>
|
|
|
|
</span>
|
2021-06-18 00:52:21 +02:00
|
|
|
<Button
|
|
|
|
button="secondary"
|
|
|
|
label={__('Sign Up')}
|
|
|
|
navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`}
|
|
|
|
disabled={user === null}
|
|
|
|
/>{' '}
|
2021-03-19 23:34:42 +01:00
|
|
|
</div>
|
|
|
|
);
|
2020-11-10 06:21:04 +01:00
|
|
|
|
2020-11-10 17:10:09 +01:00
|
|
|
const helpLinks = (
|
|
|
|
<ul className="navigation__tertiary navigation-links--small">
|
|
|
|
<li className="navigation-link">
|
2021-10-08 21:22:03 +02:00
|
|
|
<Button label={__('FAQ and Support')} href="https://odysee.com/@OdyseeHelp:b" />
|
2020-11-10 17:10:09 +01:00
|
|
|
</li>
|
2021-11-12 16:59:11 +01:00
|
|
|
<li className="navigation-link">
|
|
|
|
<Button label={__('Community Guidelines')} href="https://odysee.com/@OdyseeHelp:b/Community-Guidelines:c" />
|
|
|
|
</li>
|
2020-11-10 17:10:09 +01:00
|
|
|
<li className="navigation-link">
|
2021-10-08 21:22:03 +02:00
|
|
|
<Button label={__('Terms')} href="https://odysee.com/$/tos" />
|
2020-11-10 17:10:09 +01:00
|
|
|
</li>
|
|
|
|
<li className="navigation-link">
|
2021-10-08 21:22:03 +02:00
|
|
|
<Button label={__('Privacy Policy')} href="https://odysee.com/$/privacypolicy" />
|
2020-11-10 17:10:09 +01:00
|
|
|
</li>
|
2021-12-13 21:23:31 +01:00
|
|
|
<li className="navigation-link" id="gdprSidebarLink">
|
2021-12-13 18:21:44 +01:00
|
|
|
<Button label={__('Cookie Settings')} onClick={() => window.Optanon && window.Optanon.ToggleInfoDisplay()} />
|
2021-11-23 16:21:33 +01:00
|
|
|
</li>
|
2020-11-10 17:10:09 +01:00
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
|
2020-01-24 19:31:49 +01:00
|
|
|
return (
|
2020-08-11 22:32:03 +02:00
|
|
|
<div
|
|
|
|
className={classnames('navigation__wrapper', {
|
2021-12-11 15:59:32 +01:00
|
|
|
'navigation__wrapper--micro': showMicroMenu,
|
2020-08-11 22:32:03 +02:00
|
|
|
'navigation__wrapper--absolute': isAbsolute,
|
|
|
|
})}
|
|
|
|
>
|
2021-12-11 15:59:32 +01:00
|
|
|
<nav
|
|
|
|
aria-label={'Sidebar'}
|
|
|
|
className={classnames('navigation', {
|
|
|
|
'navigation--micro': showMicroMenu,
|
|
|
|
'navigation--push': showPushMenu,
|
|
|
|
'navigation-file-page-and-mobile': hideMenuFromView,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{(!canDisposeMenu || sidebarOpen) && (
|
|
|
|
<div className="navigation-inner-container">
|
|
|
|
<ul className="navigation-links--absolute mobile-only">
|
|
|
|
{notificationsEnabled && getLink(NOTIFICATIONS)}
|
|
|
|
{email && livestreamEnabled && getLink(GO_LIVE)}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul
|
|
|
|
className={classnames('navigation-links', {
|
|
|
|
'navigation-links--micro': showMicroMenu,
|
|
|
|
'navigation-links--absolute': shouldRenderLargeMenuPushorAbsolute,
|
|
|
|
})}
|
|
|
|
>
|
2021-11-30 16:27:37 +01:00
|
|
|
{getLink(HOME)}
|
|
|
|
{getLink(RECENT_FROM_FOLLOWING)}
|
|
|
|
{getLink(PLAYLISTS)}
|
|
|
|
</ul>
|
|
|
|
|
2021-12-11 15:59:32 +01:00
|
|
|
<ul
|
|
|
|
className={classnames('navigation-links', {
|
|
|
|
'navigation-links--micro': showMicroMenu,
|
|
|
|
'navigation-links--absolute': shouldRenderLargeMenuPushorAbsolute,
|
|
|
|
})}
|
|
|
|
>
|
2021-11-30 16:27:37 +01:00
|
|
|
{EXTRA_SIDEBAR_LINKS && (
|
|
|
|
<>
|
|
|
|
{/* $FlowFixMe -- GetLinksData should fix it's data type */}
|
|
|
|
{EXTRA_SIDEBAR_LINKS.map((linkProps) => getLink(linkProps))}
|
|
|
|
{getLink(WILD_WEST)}
|
|
|
|
</>
|
|
|
|
)}
|
2020-08-10 22:47:39 +02:00
|
|
|
</ul>
|
2021-11-30 16:27:37 +01:00
|
|
|
|
2021-12-11 15:59:32 +01:00
|
|
|
<ul className="navigation-links--absolute mobile-only">
|
|
|
|
{email && MOBILE_LINKS.map((linkProps) => getLink(linkProps))}
|
|
|
|
{!email && UNAUTH_LINKS.map((linkProps) => getLink(linkProps))}
|
|
|
|
</ul>
|
|
|
|
|
2021-11-12 16:59:11 +01:00
|
|
|
{getSubscriptionSection()}
|
|
|
|
{getFollowedTagsSection()}
|
2020-12-04 15:12:16 +01:00
|
|
|
{!isAuthenticated && sidebarOpen && unAuthNudge}
|
2020-08-26 23:16:45 +02:00
|
|
|
</div>
|
2021-12-11 15:59:32 +01:00
|
|
|
)}
|
|
|
|
{(!canDisposeMenu || sidebarOpen) && shouldRenderLargeMenuPushorAbsolute && helpLinks}
|
|
|
|
</nav>
|
|
|
|
<div
|
|
|
|
className={classnames('navigation__overlay', {
|
|
|
|
'navigation__overlay--active': isAbsolute && sidebarOpen,
|
|
|
|
})}
|
|
|
|
onClick={() => setSidebarOpen(false)}
|
|
|
|
/>
|
2020-08-11 22:32:03 +02:00
|
|
|
</div>
|
2019-06-11 20:10:58 +02:00
|
|
|
);
|
2019-01-27 01:23:47 +01:00
|
|
|
}
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2021-06-09 21:20:19 +02:00
|
|
|
function SubscriptionListItem({ subscription }: { subscription: Subscription }) {
|
|
|
|
const { uri, channelName } = subscription;
|
|
|
|
return (
|
|
|
|
<li className="navigation-link__wrapper">
|
|
|
|
<Button
|
|
|
|
navigate={uri}
|
|
|
|
className="navigation-link navigation-link--with-thumbnail"
|
|
|
|
activeClass="navigation-link--active"
|
|
|
|
>
|
ChannelThumbnail improvements
- [x] (6332) The IntersectionObserver method of lazy-loading loads cached images visibly late on slower devices. Previously, it was also showing the "broken image" icon briefly, which we mended by placing a dummy transparent image as the initial src.
- Reverted that ugly transparent image fix.
- Use the browser's built-in `loading="lazy"` instead. Sorry, Safari.
- [x] Size-optimization did not take "device pixel ratio" into account.
- When resizing an image through the CDN, we can't just take the dimensions of the tag in pixels directly -- we need to take zooming into account, otherwise the image ends up blurry.
- Previously, we quickly disabled optimization for the channel avatar in the Channel Page because of this. Now that we know the root-cause, the change was reverted and we now go through the CDN with appropriate sizes. This also improves our Web Vital scores.
- [x] Size-optimization wasn't really implemented for all ChannelThumbnail instances.
- The CDN-optimized size was hardcoded to the largest instance, so small images like sidebar thumbnails are still loading images that are unnecessarily larger.
- There's a little-bit of hardcoding of values from CSS here, but I think it's a ok compromise (not something we change often). It also doesn't need to be exact -- the "device pixel ratio" calculate will ensure it's slightly larger than what we need.
- [x] Set `width` and `height` of `<img>` to improve CLS.
- Addresses Ligthhouse complaints, although technically the shifting was addressed at the `ClaimPreviewTile` level (sub-container dimensions are well defined).
- Notes: the values don't need to be the final CSS-adjusted sizes. It just needs to be in the right aspect ratio to help the browser pre-allocate space to avoid shifts.
- [x] Add option to disable lazy-load Channel Thumbnails
- The guidelines mentioned that items that are already in the viewport should not enable `loading="lazy"`.
- We have a few areas where it doesn't make sense to lazy-load (e.g. thumbnail in Header, channel selector dropdown, publish preview, etc.).
2021-07-05 07:20:40 +02:00
|
|
|
<ChannelThumbnail xsmall uri={uri} hideStakedIndicator />
|
2021-06-09 21:20:19 +02:00
|
|
|
<span dir="auto" className="button__label">
|
|
|
|
{channelName}
|
|
|
|
</span>
|
|
|
|
</Button>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-10 22:47:39 +02:00
|
|
|
export default SideNavigation;
|