lbry-desktop/ui/component/router/view.jsx

427 lines
21 KiB
React
Raw Normal View History

2019-11-07 20:39:22 +01:00
// @flow
import React, { useEffect } from 'react';
import { Route, Redirect, Switch, withRouter } from 'react-router-dom';
2020-10-30 05:19:05 +01:00
2021-06-11 08:06:29 +02:00
import * as PAGES from 'constants/pages';
import { PAGE_TITLE } from 'constants/pageTitles';
import { useIsLargeScreen } from 'effects/use-screensize';
import { lazyImport } from 'util/lazyImport';
import { LINKED_COMMENT_QUERY_PARAM } from 'constants/comment';
import { parseURI, isURIValid } from 'util/lbryURI';
2022-03-29 08:45:59 +02:00
import { SITE_TITLE } from 'config';
import LoadingBarOneOff from 'component/loadingBarOneOff';
import { GetLinksData } from 'util/buildHomepage';
import * as CS from 'constants/claim_search';
import { buildUnseenCountStr } from 'util/notifications';
2019-11-07 20:39:22 +01:00
2021-06-11 08:06:29 +02:00
import HomePage from 'page/home';
const Code2257Page = lazyImport(() => import('web/page/code2257' /* webpackChunkName: "code2257" */));
2021-10-08 21:22:03 +02:00
const PrivacyPolicyPage = lazyImport(() => import('web/page/privacypolicy' /* webpackChunkName: "privacypolicy" */));
const TOSPage = lazyImport(() => import('web/page/tos' /* webpackChunkName: "tos" */));
const FypPage = lazyImport(() => import('web/page/fyp' /* webpackChunkName: "fyp" */));
2021-10-08 21:22:03 +02:00
const YouTubeTOSPage = lazyImport(() => import('web/page/youtubetos' /* webpackChunkName: "youtubetos" */));
2021-06-11 08:06:29 +02:00
const SignInPage = lazyImport(() => import('page/signIn' /* webpackChunkName: "signIn" */));
const SignInWalletPasswordPage = lazyImport(() =>
import('page/signInWalletPassword' /* webpackChunkName: "signInWalletPassword" */)
);
const SignUpPage = lazyImport(() => import('page/signUp' /* webpackChunkName: "signUp" */));
const SignInVerifyPage = lazyImport(() => import('page/signInVerify' /* webpackChunkName: "signInVerify" */));
2021-06-11 08:06:29 +02:00
const BuyPage = lazyImport(() => import('page/buy' /* webpackChunkName: "buy" */));
const ReceivePage = lazyImport(() => import('page/receive' /* webpackChunkName: "receive" */));
const SendPage = lazyImport(() => import('page/send' /* webpackChunkName: "send" */));
const SwapPage = lazyImport(() => import('page/swap' /* webpackChunkName: "swap" */));
const WalletPage = lazyImport(() => import('page/wallet' /* webpackChunkName: "wallet" */));
2021-06-11 08:06:29 +02:00
const NotificationsPage = lazyImport(() => import('page/notifications' /* webpackChunkName: "notifications" */));
const CollectionPage = lazyImport(() => import('page/collection' /* webpackChunkName: "collection" */));
const ChannelNew = lazyImport(() => import('page/channelNew' /* webpackChunkName: "channelNew" */));
const ChannelsFollowingDiscoverPage = lazyImport(() =>
import('page/channelsFollowingDiscover' /* webpackChunkName: "channelsFollowingDiscover" */)
);
const ChannelsFollowingPage = lazyImport(() =>
import('page/channelsFollowing' /* webpackChunkName: "channelsFollowing" */)
);
2022-03-01 04:19:20 +01:00
const ChannelsFollowingManage = lazyImport(() =>
import('page/channelsFollowingManage' /* webpackChunkName: "channelsFollowing" */)
);
const ChannelsPage = lazyImport(() => import('page/channels' /* webpackChunkName: "channels" */));
const CheckoutPage = lazyImport(() => import('page/checkoutPage' /* webpackChunkName: "checkoutPage" */));
const CreatorDashboard = lazyImport(() => import('page/creatorDashboard' /* webpackChunkName: "creatorDashboard" */));
const DiscoverPage = lazyImport(() => import('page/discover' /* webpackChunkName: "discover" */));
const EmbedWrapperPage = lazyImport(() => import('page/embedWrapper' /* webpackChunkName: "embedWrapper" */));
const PopoutChatPage = lazyImport(() => import('page/popoutChatWrapper' /* webpackChunkName: "popoutChat" */));
const FileListPublished = lazyImport(() =>
import('page/fileListPublished' /* webpackChunkName: "fileListPublished" */)
);
const FourOhFourPage = lazyImport(() => import('page/fourOhFour' /* webpackChunkName: "fourOhFour" */));
const HelpPage = lazyImport(() => import('page/help' /* webpackChunkName: "help" */));
const InvitePage = lazyImport(() => import('page/invite' /* webpackChunkName: "invite" */));
const InvitedPage = lazyImport(() => import('page/invited' /* webpackChunkName: "invited" */));
const LibraryPage = lazyImport(() => import('page/library' /* webpackChunkName: "library" */));
const ListBlockedPage = lazyImport(() => import('page/listBlocked' /* webpackChunkName: "listBlocked" */));
const ListsPage = lazyImport(() => import('page/lists' /* webpackChunkName: "lists" */));
const PlaylistsPage = lazyImport(() => import('page/playlists' /* webpackChunkName: "lists" */));
2022-05-03 13:21:51 +02:00
const WatchHistoryPage = lazyImport(() => import('page/watchHistory' /* webpackChunkName: "history" */));
const LiveStreamSetupPage = lazyImport(() => import('page/livestreamSetup' /* webpackChunkName: "livestreamSetup" */));
const LivestreamCurrentPage = lazyImport(() =>
import('page/livestreamCurrent' /* webpackChunkName: "livestreamCurrent" */)
);
Publish revamp (Part 2) (#1781) * Move menu entries & add publish buttons * Save * Separate publish forms * Make new header dynamic for all screen sizes * Save some livestream creation changes * Save more livestream changes * Save * Change publish folder structure * Update paths * Change position of form elements. Again. * Move, add & delete form fields * Clean post form * Clean post form even more * Clean publish post component * Save * Add custom post form state * Move price to additional options * Adjust livestream form * Adjust headers & titles * Update key section * Adjust active header icons * Adjust toggle menu * Save * Adjust active button style * Change active button selector in header * Fix header menu links * Move price section in post form * Adjust instruction text color * Adjust replay table * Revert changes & adjust tag section * Make more form elements dynamic * Finalize additional options section * Update post form * Set mode in upload form * Update livestream form * Add clear button * Make clear button dynamic * Set upload mode * Remove new button * Clean upload form * Show disabled key on livestream form * Remove old key section * Update channel selector for publish forms * Add updated channel selector to publish forms * Add mobile links * Update mobile header * Adjust channel selector on mobile * Adjust livestream form on mobile * Adjust edit links for livestreams * Adjust edit links for posts * Adjust more edit links * Adjust channel selector * Update disabled in livestream form * Add missing change * Fix sign out function * Save * Adjust livestream page on mobile * Adjust tags section on upload page on mobile * Adjust publish links in left navigation on mobile * Add images to accepted filetypes on upload page * Add autofocus to input fields * Add autofocus to all publish forms * Save * Ignore thumbnail api status * Put active thumbnail upload label in card * Fix crashes * Fix flow * Fix licence fields * Adjust wallet in header on smaller screens * Fix channel selector line break on small screens * Fix border radius for some buttons * PublishReleaseDate: fix initial value to reflect what's actually in Redux 'undefined' is a valid value that means "use publish time", but the GUI incorrectly starts off by locking to the mounted timestamp. * Add and hide channel selector on livestream publish page * Fix channel selector on livestream setup page * Fix gif aspect ratio in channel selector * Make layout more dynamic * Fix some edit redirects * Save * Clean publishFile * Fix build errors * Fix more build errors in profile menu button * Remove console logs * Remove post form reducer * Limit publish title length to 200 characters * Remove totalRewardValue from livestreamCreate index * Remove console log * Add tooltip to replay refresh button * Remove scrollToTop function from publish forms * Adjust emty wallet value trigger and add error to livestream publish page * Disable some tabs in edit mode in livestream form * Fix maxLength typo * Remove 'as' label * Remove selectPublishFormValues * Reenable setup tab * Remove inactive line * Remove another inactive line * Remove flow fix * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile * Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode * Hide replay options in edit mode in livestream form * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode Hide replay options in edit mode in livestream form * Make form titles dynamic * Remove spinner on livestream form * Remove console log * Fix double history push * Fix thumbnail status on post form * Update error message style * Handle publish error button behavior * Clean code * Fix scheduling & date picker * Fix calendar overlap * Add replay selector to livestream claim edit form * Clean code * Disable autocomplete * Show replays in edit & replay tab * Redesign replay picker * Fix design details * Save dynamic replay picker * Fix autoComplete typo * Change label text * Add upload to livestream replay form * Fix scss structure * Add comunity guideline link to publish forms * Fix error * Fix selectThumbnail index * Reset form values on replay source change * Add replay redirect to upload page * Fix publishError state change * Remove label effect from publish confirmation modal * Update labels in publish confirmation modal * Add ? to chaptersButton * Remove doPrepareEdit({ name }) * Bring upload redirect back * Adjust redirects * Save * Update edit redirects * Revert scheduling options * Replace checkboxes for replays with radio * Update form on source change * Rearrange entries in mobile navigation * Change key position on livestream setup page * Change label for livestream update without replay change * Adjust margin below label Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
2022-07-11 16:12:37 +02:00
const LivestreamCreatePage = lazyImport(() =>
import('page/livestreamCreate' /* webpackChunkName: "livestreamCreate" */)
);
const OdyseeMembershipPage = lazyImport(() =>
import('page/odyseeMembership' /* webpackChunkName: "odyseeMembership" */)
);
const OwnComments = lazyImport(() => import('page/ownComments' /* webpackChunkName: "ownComments" */));
const PasswordResetPage = lazyImport(() => import('page/passwordReset' /* webpackChunkName: "passwordReset" */));
const PasswordSetPage = lazyImport(() => import('page/passwordSet' /* webpackChunkName: "passwordSet" */));
Publish revamp (Part 2) (#1781) * Move menu entries & add publish buttons * Save * Separate publish forms * Make new header dynamic for all screen sizes * Save some livestream creation changes * Save more livestream changes * Save * Change publish folder structure * Update paths * Change position of form elements. Again. * Move, add & delete form fields * Clean post form * Clean post form even more * Clean publish post component * Save * Add custom post form state * Move price to additional options * Adjust livestream form * Adjust headers & titles * Update key section * Adjust active header icons * Adjust toggle menu * Save * Adjust active button style * Change active button selector in header * Fix header menu links * Move price section in post form * Adjust instruction text color * Adjust replay table * Revert changes & adjust tag section * Make more form elements dynamic * Finalize additional options section * Update post form * Set mode in upload form * Update livestream form * Add clear button * Make clear button dynamic * Set upload mode * Remove new button * Clean upload form * Show disabled key on livestream form * Remove old key section * Update channel selector for publish forms * Add updated channel selector to publish forms * Add mobile links * Update mobile header * Adjust channel selector on mobile * Adjust livestream form on mobile * Adjust edit links for livestreams * Adjust edit links for posts * Adjust more edit links * Adjust channel selector * Update disabled in livestream form * Add missing change * Fix sign out function * Save * Adjust livestream page on mobile * Adjust tags section on upload page on mobile * Adjust publish links in left navigation on mobile * Add images to accepted filetypes on upload page * Add autofocus to input fields * Add autofocus to all publish forms * Save * Ignore thumbnail api status * Put active thumbnail upload label in card * Fix crashes * Fix flow * Fix licence fields * Adjust wallet in header on smaller screens * Fix channel selector line break on small screens * Fix border radius for some buttons * PublishReleaseDate: fix initial value to reflect what's actually in Redux 'undefined' is a valid value that means "use publish time", but the GUI incorrectly starts off by locking to the mounted timestamp. * Add and hide channel selector on livestream publish page * Fix channel selector on livestream setup page * Fix gif aspect ratio in channel selector * Make layout more dynamic * Fix some edit redirects * Save * Clean publishFile * Fix build errors * Fix more build errors in profile menu button * Remove console logs * Remove post form reducer * Limit publish title length to 200 characters * Remove totalRewardValue from livestreamCreate index * Remove console log * Add tooltip to replay refresh button * Remove scrollToTop function from publish forms * Adjust emty wallet value trigger and add error to livestream publish page * Disable some tabs in edit mode in livestream form * Fix maxLength typo * Remove 'as' label * Remove selectPublishFormValues * Reenable setup tab * Remove inactive line * Remove another inactive line * Remove flow fix * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile * Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode * Hide replay options in edit mode in livestream form * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode Hide replay options in edit mode in livestream form * Make form titles dynamic * Remove spinner on livestream form * Remove console log * Fix double history push * Fix thumbnail status on post form * Update error message style * Handle publish error button behavior * Clean code * Fix scheduling & date picker * Fix calendar overlap * Add replay selector to livestream claim edit form * Clean code * Disable autocomplete * Show replays in edit & replay tab * Redesign replay picker * Fix design details * Save dynamic replay picker * Fix autoComplete typo * Change label text * Add upload to livestream replay form * Fix scss structure * Add comunity guideline link to publish forms * Fix error * Fix selectThumbnail index * Reset form values on replay source change * Add replay redirect to upload page * Fix publishError state change * Remove label effect from publish confirmation modal * Update labels in publish confirmation modal * Add ? to chaptersButton * Remove doPrepareEdit({ name }) * Bring upload redirect back * Adjust redirects * Save * Update edit redirects * Revert scheduling options * Replace checkboxes for replays with radio * Update form on source change * Rearrange entries in mobile navigation * Change key position on livestream setup page * Change label for livestream update without replay change * Adjust margin below label Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
2022-07-11 16:12:37 +02:00
const UploadPage = lazyImport(() => import('page/upload' /* webpackChunkName: "publish" */));
const PostPage = lazyImport(() => import('page/post' /* webpackChunkName: "post" */));
const ReportContentPage = lazyImport(() => import('page/reportContent' /* webpackChunkName: "reportContent" */));
const ReportPage = lazyImport(() => import('page/report' /* webpackChunkName: "report" */));
const RepostNew = lazyImport(() => import('page/repost' /* webpackChunkName: "repost" */));
const RewardsPage = lazyImport(() => import('page/rewards' /* webpackChunkName: "rewards" */));
const RewardsVerifyPage = lazyImport(() => import('page/rewardsVerify' /* webpackChunkName: "rewardsVerify" */));
const SearchPage = lazyImport(() => import('page/search' /* webpackChunkName: "search" */));
const SettingsStripeCard = lazyImport(() =>
import('page/settingsStripeCard' /* webpackChunkName: "settingsStripeCard" */)
);
const SettingsStripeAccount = lazyImport(() =>
import('page/settingsStripeAccount' /* webpackChunkName: "settingsStripeAccount" */)
);
const SettingsCreatorPage = lazyImport(() => import('page/settingsCreator' /* webpackChunkName: "settingsCreator" */));
const SettingsNotificationsPage = lazyImport(() =>
import('page/settingsNotifications' /* webpackChunkName: "settingsNotifications" */)
);
const SettingsPage = lazyImport(() => import('page/settings' /* webpackChunkName: "settings" */));
const ShowPage = lazyImport(() => import('page/show' /* webpackChunkName: "show" */));
const TagsFollowingManagePage = lazyImport(() =>
import('page/tagsFollowingManage' /* webpackChunkName: "tagsFollowingManage" */)
);
const TagsFollowingPage = lazyImport(() => import('page/tagsFollowing' /* webpackChunkName: "tagsFollowing" */));
const TopPage = lazyImport(() => import('page/top' /* webpackChunkName: "top" */));
2021-08-23 08:18:27 +02:00
const UpdatePasswordPage = lazyImport(() => import('page/passwordUpdate' /* webpackChunkName: "passwordUpdate" */));
const YoutubeSyncPage = lazyImport(() => import('page/youtubeSync' /* webpackChunkName: "youtubeSync" */));
2019-11-07 20:39:22 +01:00
// Tell the browser we are handling scroll restoration
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
type Props = {
currentScroll: number,
isAuthenticated: boolean,
location: { pathname: string, search: string, hash: string },
2020-01-25 21:37:02 +01:00
history: {
action: string,
2020-01-25 21:37:02 +01:00
entries: { title: string }[],
goBack: () => void,
goForward: () => void,
index: number,
length: number,
location: { pathname: string },
push: (string) => void,
2020-01-25 21:37:02 +01:00
state: {},
replaceState: ({}, string, string) => void,
listen: (any) => () => void,
2020-01-25 21:37:02 +01:00
},
uri: string,
title: string,
hasNavigated: boolean,
setHasNavigated: () => void,
setReferrer: (?string) => void,
hasUnclaimedRefereeReward: boolean,
homepageData: any,
2022-02-15 18:36:33 +01:00
wildWestDisabled: boolean,
unseenCount: number,
hideTitleNotificationCount: boolean,
2022-05-04 15:59:10 +02:00
hasDefaultChannel: boolean,
doSetActiveChannel: (claimId: ?string, override?: boolean) => void,
2022-05-09 16:47:17 +02:00
embedLatestPath: ?boolean,
2019-11-07 20:39:22 +01:00
};
2020-10-30 05:19:05 +01:00
type PrivateRouteProps = Props & {
component: any,
isAuthenticated: boolean,
};
function PrivateRoute(props: PrivateRouteProps) {
const { component: Component, isAuthenticated, ...rest } = props;
const urlSearchParams = new URLSearchParams(props.location.search);
const redirectUrl = urlSearchParams.get('redirect');
2020-10-30 05:19:05 +01:00
return (
<Route
{...rest}
render={(props) =>
2020-10-30 05:19:05 +01:00
isAuthenticated || !IS_WEB ? (
<Component {...props} />
) : (
<Redirect to={`/$/${PAGES.AUTH}?redirect=${redirectUrl || props.location.pathname}`} />
2020-10-30 05:19:05 +01:00
)
}
/>
);
}
2019-11-07 20:39:22 +01:00
function AppRouter(props: Props) {
const {
currentScroll,
location: { pathname, search, hash },
isAuthenticated,
2020-01-25 21:37:02 +01:00
history,
uri,
title,
hasNavigated,
setHasNavigated,
hasUnclaimedRefereeReward,
setReferrer,
homepageData,
2022-02-15 18:36:33 +01:00
wildWestDisabled,
unseenCount,
hideTitleNotificationCount,
2022-05-04 15:59:10 +02:00
hasDefaultChannel,
doSetActiveChannel,
2022-05-09 16:47:17 +02:00
embedLatestPath,
} = props;
2022-02-15 18:36:33 +01:00
2022-05-04 15:59:10 +02:00
const defaultChannelRef = React.useRef(hasDefaultChannel);
const { entries, listen, action: historyAction } = history;
2020-01-25 21:37:02 +01:00
const entryIndex = history.index;
const urlParams = new URLSearchParams(search);
const resetScroll = urlParams.get('reset_scroll');
const hasLinkedCommentInUrl = urlParams.get(LINKED_COMMENT_QUERY_PARAM);
const tagParams = urlParams.get(CS.TAGS_KEY);
const isLargeScreen = useIsLargeScreen();
2020-01-25 21:37:02 +01:00
const categoryPages = React.useMemo(() => {
const dynamicRoutes = GetLinksData(homepageData, isLargeScreen).filter(
(x: any) => x && x.route && (x.id !== 'WILD_WEST' || !wildWestDisabled)
);
return dynamicRoutes.map((dynamicRouteProps: RowDataItem) => (
<Route
key={dynamicRouteProps.route}
path={dynamicRouteProps.route}
component={(routerProps) => <DiscoverPage {...routerProps} dynamicRouteProps={dynamicRouteProps} />}
/>
));
}, [homepageData, isLargeScreen, wildWestDisabled]);
// For people arriving at settings page from deeplinks, know whether they can "go back"
useEffect(() => {
const unlisten = listen((location, action) => {
if (action === 'PUSH') {
if (!hasNavigated && setHasNavigated) setHasNavigated();
}
});
return unlisten;
}, [listen, hasNavigated, setHasNavigated]);
useEffect(() => {
if (!hasNavigated && hasUnclaimedRefereeReward && !isAuthenticated) {
const valid = isURIValid(uri);
if (valid) {
const { path } = parseURI(uri);
if (path !== 'undefined') setReferrer(path);
}
}
}, [hasNavigated, uri, hasUnclaimedRefereeReward, setReferrer, isAuthenticated]);
2020-01-25 21:37:02 +01:00
useEffect(() => {
const getDefaultTitle = (pathname: string) => {
let title = '';
if (pathname.startsWith('/$/')) {
const name = pathname.substring(3);
if (window.CATEGORY_PAGE_TITLE && window.CATEGORY_PAGE_TITLE[name]) {
title = window.CATEGORY_PAGE_TITLE[name];
} else {
title = PAGE_TITLE[name];
}
}
return __(title) || SITE_TITLE || 'Odysee';
};
2020-02-13 02:48:28 +01:00
if (uri) {
const { channelName, streamName } = parseURI(uri);
2021-04-05 04:53:13 +02:00
if (title) {
2020-02-13 02:48:28 +01:00
document.title = title;
2021-04-05 04:53:13 +02:00
} else if (streamName) {
2020-02-13 02:48:28 +01:00
document.title = streamName;
2021-04-05 04:53:13 +02:00
} else if (channelName) {
2020-02-13 02:48:28 +01:00
document.title = channelName;
} else {
document.title = getDefaultTitle(pathname);
2020-02-13 02:48:28 +01:00
}
2020-01-25 21:37:02 +01:00
} else {
document.title = getDefaultTitle(pathname);
2020-01-25 21:37:02 +01:00
}
if (unseenCount > 0 && !hideTitleNotificationCount) {
document.title = `(${buildUnseenCountStr(unseenCount)}) ${document.title}`;
}
}, [pathname, entries, entryIndex, title, uri, unseenCount, hideTitleNotificationCount]);
2019-11-07 20:39:22 +01:00
useEffect(() => {
if (!hasLinkedCommentInUrl) {
if (hash && historyAction === 'PUSH') {
const id = hash.replace('#', '');
const element = document.getElementById(id);
if (element) {
window.scrollTo(0, element.offsetTop);
}
} else {
window.scrollTo(0, currentScroll);
}
}
}, [currentScroll, pathname, search, hash, resetScroll, hasLinkedCommentInUrl, historyAction]);
2019-11-07 20:39:22 +01:00
2022-05-04 15:59:10 +02:00
React.useEffect(() => {
defaultChannelRef.current = hasDefaultChannel;
}, [hasDefaultChannel]);
React.useEffect(() => {
// has a default channel selected, clear the current active channel
if (
defaultChannelRef.current &&
pathname !== `/$/${PAGES.UPLOAD}` &&
!pathname.includes(`/$/${PAGES.LIST}/`) &&
pathname !== `/$/${PAGES.CREATOR_DASHBOARD}` &&
pathname !== `/$/${PAGES.LIVESTREAM}`
) {
doSetActiveChannel(null, true);
}
// only on pathname change
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pathname]);
2020-01-29 21:21:03 +01:00
// react-router doesn't decode pathanmes before doing the route matching check
// We have to redirect here because if we redirect on the server, it might get encoded again
// in the browser causing a redirect loop
const decodedUrl = decodeURIComponent(pathname) + search;
if (decodedUrl !== pathname + search) {
return <Redirect to={decodedUrl} />;
2020-01-29 21:21:03 +01:00
}
2019-11-07 20:39:22 +01:00
return (
<React.Suspense fallback={<LoadingBarOneOff />}>
<Switch>
<Redirect
from={`/$/${PAGES.DEPRECATED__CHANNELS_FOLLOWING_MANAGE}`}
to={`/$/${PAGES.CHANNELS_FOLLOWING_DISCOVER}`}
/>
<Redirect from={`/$/${PAGES.DEPRECATED__CHANNELS_FOLLOWING}`} to={`/$/${PAGES.CHANNELS_FOLLOWING}`} />
<Redirect from={`/$/${PAGES.DEPRECATED__TAGS_FOLLOWING}`} to={`/$/${PAGES.TAGS_FOLLOWING}`} />
<Redirect from={`/$/${PAGES.DEPRECATED__TAGS_FOLLOWING_MANAGE}`} to={`/$/${PAGES.TAGS_FOLLOWING_MANAGE}`} />
<Redirect from={`/$/${PAGES.DEPRECATED__PUBLISH}`} to={`/$/${PAGES.UPLOAD}`} />
<Redirect from={`/$/${PAGES.DEPRECATED__PUBLISHED}`} to={`/$/${PAGES.UPLOADS}`} />
<Route path={`/`} exact component={HomePage} />
{(!wildWestDisabled || tagParams) && <Route path={`/$/${PAGES.DISCOVER}`} exact component={DiscoverPage} />}
{categoryPages}
<Route path={`/$/${PAGES.AUTH_SIGNIN}`} exact component={SignInPage} />
<Route path={`/$/${PAGES.AUTH_PASSWORD_RESET}`} exact component={PasswordResetPage} />
<Route path={`/$/${PAGES.AUTH_PASSWORD_SET}`} exact component={PasswordSetPage} />
<Route path={`/$/${PAGES.AUTH}`} exact component={SignUpPage} />
<Route path={`/$/${PAGES.AUTH}/*`} exact component={SignUpPage} />
<Route path={`/$/${PAGES.HELP}`} exact component={HelpPage} />
<Route path={`/$/${PAGES.CODE_2257}`} exact component={Code2257Page} />
<Route path={`/$/${PAGES.PRIVACY_POLICY}`} exact component={PrivacyPolicyPage} />
<Route path={`/$/${PAGES.TOS}`} exact component={TOSPage} />
<Route path={`/$/${PAGES.FYP}`} exact component={FypPage} />
<Route path={`/$/${PAGES.YOUTUBE_TOS}`} exact component={YouTubeTOSPage} />
<Route path={`/$/${PAGES.AUTH_VERIFY}`} exact component={SignInVerifyPage} />
<Route path={`/$/${PAGES.SEARCH}`} exact component={SearchPage} />
<Route path={`/$/${PAGES.TOP}`} exact component={TopPage} />
<Route path={`/$/${PAGES.SETTINGS}`} exact component={SettingsPage} />
<Route path={`/$/${PAGES.INVITE}/:referrer`} exact component={InvitedPage} />
<Route path={`/$/${PAGES.CHECKOUT}`} exact component={CheckoutPage} />
<Route path={`/$/${PAGES.REPORT_CONTENT}`} exact component={ReportContentPage} />
<Route {...props} path={`/$/${PAGES.LIST}/:collectionId`} component={CollectionPage} />
<PrivateRoute {...props} exact path={`/$/${PAGES.YOUTUBE_SYNC}`} component={YoutubeSyncPage} />
<PrivateRoute {...props} exact path={`/$/${PAGES.TAGS_FOLLOWING}`} component={TagsFollowingPage} />
<PrivateRoute
{...props}
exact
path={`/$/${PAGES.CHANNELS_FOLLOWING}`}
component={isAuthenticated || !IS_WEB ? ChannelsFollowingPage : DiscoverPage}
/>
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_NOTIFICATIONS}`} component={SettingsNotificationsPage} />
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_STRIPE_CARD}`} component={SettingsStripeCard} />
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_STRIPE_ACCOUNT}`} component={SettingsStripeAccount} />
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_UPDATE_PWD}`} component={UpdatePasswordPage} />
<PrivateRoute
{...props}
exact
path={`/$/${PAGES.CHANNELS_FOLLOWING_DISCOVER}`}
component={ChannelsFollowingDiscoverPage}
/>
<PrivateRoute
{...props}
exact
path={`/$/${PAGES.CHANNELS_FOLLOWING_MANAGE}`}
component={ChannelsFollowingManage}
/>
<PrivateRoute {...props} path={`/$/${PAGES.INVITE}`} component={InvitePage} />
<PrivateRoute {...props} path={`/$/${PAGES.CHANNEL_NEW}`} component={ChannelNew} />
<PrivateRoute {...props} path={`/$/${PAGES.REPOST_NEW}`} component={RepostNew} />
<PrivateRoute {...props} path={`/$/${PAGES.UPLOADS}`} component={FileListPublished} />
<PrivateRoute {...props} path={`/$/${PAGES.CREATOR_DASHBOARD}`} component={CreatorDashboard} />
Publish revamp (Part 2) (#1781) * Move menu entries & add publish buttons * Save * Separate publish forms * Make new header dynamic for all screen sizes * Save some livestream creation changes * Save more livestream changes * Save * Change publish folder structure * Update paths * Change position of form elements. Again. * Move, add & delete form fields * Clean post form * Clean post form even more * Clean publish post component * Save * Add custom post form state * Move price to additional options * Adjust livestream form * Adjust headers & titles * Update key section * Adjust active header icons * Adjust toggle menu * Save * Adjust active button style * Change active button selector in header * Fix header menu links * Move price section in post form * Adjust instruction text color * Adjust replay table * Revert changes & adjust tag section * Make more form elements dynamic * Finalize additional options section * Update post form * Set mode in upload form * Update livestream form * Add clear button * Make clear button dynamic * Set upload mode * Remove new button * Clean upload form * Show disabled key on livestream form * Remove old key section * Update channel selector for publish forms * Add updated channel selector to publish forms * Add mobile links * Update mobile header * Adjust channel selector on mobile * Adjust livestream form on mobile * Adjust edit links for livestreams * Adjust edit links for posts * Adjust more edit links * Adjust channel selector * Update disabled in livestream form * Add missing change * Fix sign out function * Save * Adjust livestream page on mobile * Adjust tags section on upload page on mobile * Adjust publish links in left navigation on mobile * Add images to accepted filetypes on upload page * Add autofocus to input fields * Add autofocus to all publish forms * Save * Ignore thumbnail api status * Put active thumbnail upload label in card * Fix crashes * Fix flow * Fix licence fields * Adjust wallet in header on smaller screens * Fix channel selector line break on small screens * Fix border radius for some buttons * PublishReleaseDate: fix initial value to reflect what's actually in Redux 'undefined' is a valid value that means "use publish time", but the GUI incorrectly starts off by locking to the mounted timestamp. * Add and hide channel selector on livestream publish page * Fix channel selector on livestream setup page * Fix gif aspect ratio in channel selector * Make layout more dynamic * Fix some edit redirects * Save * Clean publishFile * Fix build errors * Fix more build errors in profile menu button * Remove console logs * Remove post form reducer * Limit publish title length to 200 characters * Remove totalRewardValue from livestreamCreate index * Remove console log * Add tooltip to replay refresh button * Remove scrollToTop function from publish forms * Adjust emty wallet value trigger and add error to livestream publish page * Disable some tabs in edit mode in livestream form * Fix maxLength typo * Remove 'as' label * Remove selectPublishFormValues * Reenable setup tab * Remove inactive line * Remove another inactive line * Remove flow fix * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile * Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode * Hide replay options in edit mode in livestream form * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode Hide replay options in edit mode in livestream form * Make form titles dynamic * Remove spinner on livestream form * Remove console log * Fix double history push * Fix thumbnail status on post form * Update error message style * Handle publish error button behavior * Clean code * Fix scheduling & date picker * Fix calendar overlap * Add replay selector to livestream claim edit form * Clean code * Disable autocomplete * Show replays in edit & replay tab * Redesign replay picker * Fix design details * Save dynamic replay picker * Fix autoComplete typo * Change label text * Add upload to livestream replay form * Fix scss structure * Add comunity guideline link to publish forms * Fix error * Fix selectThumbnail index * Reset form values on replay source change * Add replay redirect to upload page * Fix publishError state change * Remove label effect from publish confirmation modal * Update labels in publish confirmation modal * Add ? to chaptersButton * Remove doPrepareEdit({ name }) * Bring upload redirect back * Adjust redirects * Save * Update edit redirects * Revert scheduling options * Replace checkboxes for replays with radio * Update form on source change * Rearrange entries in mobile navigation * Change key position on livestream setup page * Change label for livestream update without replay change * Adjust margin below label Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
2022-07-11 16:12:37 +02:00
<PrivateRoute {...props} path={`/$/${PAGES.UPLOAD}`} component={UploadPage} />
<PrivateRoute {...props} path={`/$/${PAGES.POST}`} component={PostPage} />
<PrivateRoute {...props} path={`/$/${PAGES.REPORT}`} component={ReportPage} />
<PrivateRoute {...props} path={`/$/${PAGES.REWARDS}`} exact component={RewardsPage} />
<PrivateRoute {...props} path={`/$/${PAGES.REWARDS_VERIFY}`} component={RewardsVerifyPage} />
<PrivateRoute {...props} path={`/$/${PAGES.LIBRARY}`} component={LibraryPage} />
<PrivateRoute {...props} path={`/$/${PAGES.LISTS}`} component={ListsPage} />
<PrivateRoute {...props} path={`/$/${PAGES.PLAYLISTS}`} component={PlaylistsPage} />
<PrivateRoute {...props} path={`/$/${PAGES.WATCH_HISTORY}`} component={WatchHistoryPage} />
<PrivateRoute {...props} path={`/$/${PAGES.TAGS_FOLLOWING_MANAGE}`} component={TagsFollowingManagePage} />
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_BLOCKED_MUTED}`} component={ListBlockedPage} />
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_CREATOR}`} component={SettingsCreatorPage} />
<PrivateRoute {...props} path={`/$/${PAGES.WALLET}`} exact component={WalletPage} />
<PrivateRoute {...props} path={`/$/${PAGES.CHANNELS}`} component={ChannelsPage} />
Publish revamp (Part 2) (#1781) * Move menu entries & add publish buttons * Save * Separate publish forms * Make new header dynamic for all screen sizes * Save some livestream creation changes * Save more livestream changes * Save * Change publish folder structure * Update paths * Change position of form elements. Again. * Move, add & delete form fields * Clean post form * Clean post form even more * Clean publish post component * Save * Add custom post form state * Move price to additional options * Adjust livestream form * Adjust headers & titles * Update key section * Adjust active header icons * Adjust toggle menu * Save * Adjust active button style * Change active button selector in header * Fix header menu links * Move price section in post form * Adjust instruction text color * Adjust replay table * Revert changes & adjust tag section * Make more form elements dynamic * Finalize additional options section * Update post form * Set mode in upload form * Update livestream form * Add clear button * Make clear button dynamic * Set upload mode * Remove new button * Clean upload form * Show disabled key on livestream form * Remove old key section * Update channel selector for publish forms * Add updated channel selector to publish forms * Add mobile links * Update mobile header * Adjust channel selector on mobile * Adjust livestream form on mobile * Adjust edit links for livestreams * Adjust edit links for posts * Adjust more edit links * Adjust channel selector * Update disabled in livestream form * Add missing change * Fix sign out function * Save * Adjust livestream page on mobile * Adjust tags section on upload page on mobile * Adjust publish links in left navigation on mobile * Add images to accepted filetypes on upload page * Add autofocus to input fields * Add autofocus to all publish forms * Save * Ignore thumbnail api status * Put active thumbnail upload label in card * Fix crashes * Fix flow * Fix licence fields * Adjust wallet in header on smaller screens * Fix channel selector line break on small screens * Fix border radius for some buttons * PublishReleaseDate: fix initial value to reflect what's actually in Redux 'undefined' is a valid value that means "use publish time", but the GUI incorrectly starts off by locking to the mounted timestamp. * Add and hide channel selector on livestream publish page * Fix channel selector on livestream setup page * Fix gif aspect ratio in channel selector * Make layout more dynamic * Fix some edit redirects * Save * Clean publishFile * Fix build errors * Fix more build errors in profile menu button * Remove console logs * Remove post form reducer * Limit publish title length to 200 characters * Remove totalRewardValue from livestreamCreate index * Remove console log * Add tooltip to replay refresh button * Remove scrollToTop function from publish forms * Adjust emty wallet value trigger and add error to livestream publish page * Disable some tabs in edit mode in livestream form * Fix maxLength typo * Remove 'as' label * Remove selectPublishFormValues * Reenable setup tab * Remove inactive line * Remove another inactive line * Remove flow fix * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile * Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode * Hide replay options in edit mode in livestream form * Update label switch logic in confirmation modal Adjust gif margin Adjust gif margin Remove navigate from edit link Remove manual updateLabels execution on init Remove editLabel function Fix labels in publish modal Adjust post livestream setup redirect Remove setOverMaxBitrate from livestream form Clean livestream publish More cleanup Update post livestream creation redirect Bring back edit tab for livestreams Update edit tab Reset form on livestream edit => clear Update label switch logic Readjust channel selector position on mobile Make some space adjustments for mobile Update livestream edit page on mobile Update action label on publish forms in edit mode Hide replay options in edit mode in livestream form * Make form titles dynamic * Remove spinner on livestream form * Remove console log * Fix double history push * Fix thumbnail status on post form * Update error message style * Handle publish error button behavior * Clean code * Fix scheduling & date picker * Fix calendar overlap * Add replay selector to livestream claim edit form * Clean code * Disable autocomplete * Show replays in edit & replay tab * Redesign replay picker * Fix design details * Save dynamic replay picker * Fix autoComplete typo * Change label text * Add upload to livestream replay form * Fix scss structure * Add comunity guideline link to publish forms * Fix error * Fix selectThumbnail index * Reset form values on replay source change * Add replay redirect to upload page * Fix publishError state change * Remove label effect from publish confirmation modal * Update labels in publish confirmation modal * Add ? to chaptersButton * Remove doPrepareEdit({ name }) * Bring upload redirect back * Adjust redirects * Save * Update edit redirects * Revert scheduling options * Replace checkboxes for replays with radio * Update form on source change * Rearrange entries in mobile navigation * Change key position on livestream setup page * Change label for livestream update without replay change * Adjust margin below label Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
2022-07-11 16:12:37 +02:00
<PrivateRoute {...props} path={`/$/${PAGES.LIVESTREAM_CREATE}`} component={LivestreamCreatePage} />
<PrivateRoute {...props} path={`/$/${PAGES.LIVESTREAM}`} component={LiveStreamSetupPage} />
<PrivateRoute {...props} path={`/$/${PAGES.LIVESTREAM_CURRENT}`} component={LivestreamCurrentPage} />
<PrivateRoute {...props} path={`/$/${PAGES.BUY}`} component={BuyPage} />
<PrivateRoute {...props} path={`/$/${PAGES.RECEIVE}`} component={ReceivePage} />
<PrivateRoute {...props} path={`/$/${PAGES.SEND}`} component={SendPage} />
<PrivateRoute {...props} path={`/$/${PAGES.SWAP}`} component={SwapPage} />
<PrivateRoute {...props} path={`/$/${PAGES.NOTIFICATIONS}`} component={NotificationsPage} />
<PrivateRoute {...props} path={`/$/${PAGES.AUTH_WALLET_PASSWORD}`} component={SignInWalletPasswordPage} />
<PrivateRoute {...props} path={`/$/${PAGES.SETTINGS_OWN_COMMENTS}`} component={OwnComments} />
<PrivateRoute {...props} path={`/$/${PAGES.ODYSEE_MEMBERSHIP}`} component={OdyseeMembershipPage} />
<Route path={`/$/${PAGES.POPOUT}/:channelName/:streamName`} component={PopoutChatPage} />
<Route
path={`/$/${PAGES.EMBED}/:claimName`}
exact
component={embedLatestPath ? () => <EmbedWrapperPage uri={uri} /> : EmbedWrapperPage}
/>
<Route path={`/$/${PAGES.EMBED}/:claimName/:claimId`} exact component={EmbedWrapperPage} />
{/* Below need to go at the end to make sure we don't match any of our pages first */}
<Route path={`/$/${PAGES.LATEST}/:channelName`} exact render={() => <ShowPage uri={uri} latestContentPath />} />
<Route path={`/$/${PAGES.LIVE_NOW}/:channelName`} exact render={() => <ShowPage uri={uri} liveContentPath />} />
<Route path="/:claimName" exact render={() => <ShowPage uri={uri} />} />
<Route path="/:claimName/:streamName" exact render={() => <ShowPage uri={uri} />} />
<Route path="/*" component={FourOhFourPage} />
</Switch>
2021-06-11 08:06:29 +02:00
</React.Suspense>
2019-11-07 20:39:22 +01:00
);
}
export default withRouter(AppRouter);