2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2019-10-22 19:57:32 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2022-03-22 08:35:45 +01:00
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
2021-07-07 09:10:28 +02:00
|
|
|
import { lazyImport } from 'util/lazyImport';
|
2021-12-07 15:48:09 +01:00
|
|
|
import { tusUnlockAndNotify, tusHandleTabUpdates } from 'util/tus';
|
2019-07-22 04:28:49 +02:00
|
|
|
import analytics from 'analytics';
|
2021-11-24 21:25:22 +01:00
|
|
|
import { setSearchUserId } from 'redux/actions/search';
|
2022-05-13 15:14:05 +02:00
|
|
|
import { normalizeURI } from 'util/lbryURI';
|
|
|
|
import { generateGoogleCacheUrl } from 'util/url';
|
2017-12-21 22:08:54 +01:00
|
|
|
import Router from 'component/router/index';
|
2021-10-26 08:15:08 +02:00
|
|
|
import ModalRouter from 'modal/modalRouter';
|
2017-12-21 22:08:54 +01:00
|
|
|
import ReactModal from 'react-modal';
|
2019-06-11 20:10:58 +02:00
|
|
|
import useKonamiListener from 'util/enhanced-layout';
|
2021-10-26 08:15:08 +02:00
|
|
|
import Yrbl from 'component/yrbl';
|
2020-04-01 20:43:50 +02:00
|
|
|
import FileRenderFloating from 'component/fileRenderFloating';
|
2019-08-13 07:35:13 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2022-03-18 01:58:06 +01:00
|
|
|
import useAdOutbrain from 'effects/use-ad-outbrain';
|
2019-09-27 20:56:15 +02:00
|
|
|
import usePrevious from 'effects/use-previous';
|
2021-10-26 08:15:08 +02:00
|
|
|
import Nag from 'component/common/nag';
|
2020-06-15 22:33:03 +02:00
|
|
|
import REWARDS from 'rewards';
|
2020-02-21 21:44:58 +01:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2021-12-20 09:42:19 +01:00
|
|
|
import useConnectionStatus from 'effects/use-connection-status';
|
2020-10-28 17:02:06 +01:00
|
|
|
import Spinner from 'component/spinner';
|
2021-07-16 19:51:08 +02:00
|
|
|
import LANGUAGES from 'constants/languages';
|
2021-10-26 08:15:08 +02:00
|
|
|
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
|
2020-03-17 16:21:26 +01:00
|
|
|
import {
|
|
|
|
useDegradedPerformance,
|
|
|
|
STATUS_OK,
|
|
|
|
STATUS_DEGRADED,
|
2020-03-26 21:17:41 +01:00
|
|
|
STATUS_FAILING,
|
2020-03-17 16:21:26 +01:00
|
|
|
STATUS_DOWN,
|
2020-05-07 20:44:11 +02:00
|
|
|
} from 'web/effects/use-degraded-performance';
|
2021-04-06 21:15:08 +02:00
|
|
|
import LANGUAGE_MIGRATIONS from 'constants/language-migrations';
|
2021-12-21 14:47:24 +01:00
|
|
|
import { useIsMobile } from 'effects/use-screensize';
|
2022-03-02 15:44:01 +01:00
|
|
|
import getLanguagesForCountry from 'constants/country_languages';
|
|
|
|
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
2021-06-11 08:06:29 +02:00
|
|
|
|
2021-10-26 08:15:08 +02:00
|
|
|
const FileDrop = lazyImport(() => import('component/fileDrop' /* webpackChunkName: "fileDrop" */));
|
|
|
|
const NagContinueFirstRun = lazyImport(() => import('component/nagContinueFirstRun' /* webpackChunkName: "nagCFR" */));
|
2022-03-02 15:44:01 +01:00
|
|
|
const NagLocaleSwitch = lazyImport(() => import('component/nagLocaleSwitch' /* webpackChunkName: "nagLocaleSwitch" */));
|
2021-07-15 08:12:18 +02:00
|
|
|
const NagDegradedPerformance = lazyImport(() =>
|
2021-10-26 08:15:08 +02:00
|
|
|
import('web/component/nag-degraded-performance' /* webpackChunkName: "NagDegradedPerformance" */)
|
2021-07-15 08:12:18 +02:00
|
|
|
);
|
2021-07-07 09:10:28 +02:00
|
|
|
const NagNoUser = lazyImport(() => import('web/component/nag-no-user' /* webpackChunkName: "nag-no-user" */));
|
2021-10-26 08:15:08 +02:00
|
|
|
const NagSunset = lazyImport(() => import('web/component/nag-sunset' /* webpackChunkName: "nag-sunset" */));
|
2021-07-07 09:10:28 +02:00
|
|
|
const SyncFatalError = lazyImport(() => import('component/syncFatalError' /* webpackChunkName: "syncFatalError" */));
|
2021-06-14 13:58:33 +02:00
|
|
|
|
2021-06-11 08:06:29 +02:00
|
|
|
// ****************************************************************************
|
|
|
|
|
2019-06-27 08:18:45 +02:00
|
|
|
export const MAIN_WRAPPER_CLASS = 'main-wrapper';
|
2020-11-23 19:47:36 +01:00
|
|
|
export const IS_MAC = navigator.userAgent.indexOf('Mac OS X') !== -1;
|
2019-06-27 08:18:45 +02:00
|
|
|
|
2021-12-15 19:59:02 +01:00
|
|
|
// const imaLibraryPath = 'https://imasdk.googleapis.com/js/sdkloader/ima3.js';
|
2021-12-09 18:59:15 +01:00
|
|
|
const oneTrustScriptSrc = 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js';
|
2021-10-13 17:04:03 +02:00
|
|
|
|
2022-05-09 14:26:04 +02:00
|
|
|
const LATEST_PATH = `/$/${PAGES.LATEST}/`;
|
|
|
|
const LIVE_PATH = `/$/${PAGES.LIVE_NOW}/`;
|
2022-05-09 16:47:17 +02:00
|
|
|
const EMBED_PATH = `/$/${PAGES.EMBED}/`;
|
2022-05-09 14:26:04 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
2019-06-07 23:10:47 +02:00
|
|
|
language: string,
|
2019-11-08 21:51:42 +01:00
|
|
|
languages: Array<string>,
|
2018-10-19 17:27:14 +02:00
|
|
|
theme: string,
|
2019-08-14 18:28:13 +02:00
|
|
|
user: ?{ id: string, has_verified_email: boolean, is_reward_approved: boolean },
|
2022-03-17 07:12:16 +01:00
|
|
|
locale: ?LocaleInfo,
|
2022-05-13 15:14:05 +02:00
|
|
|
location: { pathname: string, hash: string, search: string, hostname: string, reload: () => void },
|
|
|
|
history: { push: (string) => void, location: { pathname: string }, replace: (string) => void },
|
2019-09-26 18:28:08 +02:00
|
|
|
fetchChannelListMine: () => void,
|
wip
wip
wip - everything but publish, autoplay, and styling
collection publishing
add channel to collection publish
cleanup
wip
bump
clear mass add after success
move collection item management controls
redirect replace to published collection id
bump
playlist selector on create
bump
use new collection add ui element
bump
wip
gitignore
add content json
wip
bump
context add to playlist
basic collections page style pass wip
wip: edits, buttons, styles...
change fileAuthor to claimAuthor
update, pending bugfixes, delete modal progress, collection header, other bugfixes
bump
cleaning
show page bugfix
builtin collection headers
no playlists, no grid title
wip
style tweaks
use normal looking claim previews for collection tiles
add collection changes
style library previews
collection menulist for delete/view on library
delete modal works for unpublished
rearrange collection publish tabs
clean up collection publishing and items
show on odysee
begin collectoin edit header and css renaming
better thumbnails
bump
fix collection publish redirect
view collection in menu does something
copy and thumbs
list previews, pending, context menus, list page
enter to add collection, lists page empty state
playable lists only, delete feature, bump
put fileListDownloaded back
better collection titles
improve collection claim details
fix horiz more icon
fix up channel page
style, copy, bump
refactor preview overlay properties,
fix reposts showing as floppydisk
add watch later toast,
small overlay properties on wunderbar results,
fix collection actions buttons
bump
cleanup
cleaning, refactoring
bump
preview thumb styling, cleanup
support discover page lists search
sync, bump
bump, fix sync more
enforce builtin order for now
new lists page empty state
try to indicate unpublished edits in lists
bump
fix autoplay and linting
consts, fix autoplay
bugs
fixes
cleanup
fix, bump
lists experimental ui, fixes
refactor listIndex out
hack in collection fallback thumb
bump
2021-02-06 08:03:51 +01:00
|
|
|
fetchCollectionListMine: () => void,
|
2019-10-01 06:53:33 +02:00
|
|
|
signIn: () => void,
|
2021-03-03 19:50:16 +01:00
|
|
|
setLanguage: (string) => void,
|
2021-10-27 17:07:06 +02:00
|
|
|
isReloadRequired: boolean,
|
2019-10-11 02:37:18 +02:00
|
|
|
uploadCount: number,
|
2019-10-17 17:27:41 +02:00
|
|
|
balance: ?number,
|
2021-12-06 15:38:26 +01:00
|
|
|
syncIsLocked: boolean,
|
2019-10-22 19:57:32 +02:00
|
|
|
syncError: ?string,
|
2022-05-18 11:13:14 +02:00
|
|
|
prefsReady: boolean,
|
2020-01-14 21:44:07 +01:00
|
|
|
rewards: Array<Reward>,
|
|
|
|
setReferrer: (string, boolean) => void,
|
2020-03-12 02:43:52 +01:00
|
|
|
isAuthenticated: boolean,
|
2021-01-21 20:50:51 +01:00
|
|
|
syncLoop: (?boolean) => void,
|
2020-09-18 19:26:00 +02:00
|
|
|
currentModal: any,
|
2020-11-12 18:38:28 +01:00
|
|
|
syncFatalError: boolean,
|
2022-02-18 14:14:54 +01:00
|
|
|
activeChannelClaim: ?ChannelClaim,
|
2021-12-06 15:38:26 +01:00
|
|
|
myChannelClaimIds: ?Array<string>,
|
2022-03-18 01:58:06 +01:00
|
|
|
hasPremiumPlus: ?boolean,
|
2021-03-03 19:50:16 +01:00
|
|
|
setIncognito: (boolean) => void,
|
|
|
|
fetchModBlockedList: () => void,
|
2021-06-04 08:43:36 +02:00
|
|
|
fetchModAmIList: () => void,
|
2022-03-21 14:25:14 +01:00
|
|
|
homepageFetched: boolean,
|
2022-05-24 12:18:26 +02:00
|
|
|
defaultChannelClaim: ?any,
|
2022-05-18 11:13:14 +02:00
|
|
|
doOpenAnnouncements: () => void,
|
2022-05-18 11:19:51 +02:00
|
|
|
doSetLastViewedAnnouncement: (hash: string) => void,
|
2022-05-24 12:18:26 +02:00
|
|
|
doSetDefaultChannel: (claimId: string) => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
function App(props: Props) {
|
2019-09-23 03:56:43 +02:00
|
|
|
const {
|
|
|
|
theme,
|
|
|
|
user,
|
2022-03-17 07:12:16 +01:00
|
|
|
locale,
|
2022-05-13 15:14:05 +02:00
|
|
|
location,
|
2019-09-26 18:07:11 +02:00
|
|
|
fetchChannelListMine,
|
wip
wip
wip - everything but publish, autoplay, and styling
collection publishing
add channel to collection publish
cleanup
wip
bump
clear mass add after success
move collection item management controls
redirect replace to published collection id
bump
playlist selector on create
bump
use new collection add ui element
bump
wip
gitignore
add content json
wip
bump
context add to playlist
basic collections page style pass wip
wip: edits, buttons, styles...
change fileAuthor to claimAuthor
update, pending bugfixes, delete modal progress, collection header, other bugfixes
bump
cleaning
show page bugfix
builtin collection headers
no playlists, no grid title
wip
style tweaks
use normal looking claim previews for collection tiles
add collection changes
style library previews
collection menulist for delete/view on library
delete modal works for unpublished
rearrange collection publish tabs
clean up collection publishing and items
show on odysee
begin collectoin edit header and css renaming
better thumbnails
bump
fix collection publish redirect
view collection in menu does something
copy and thumbs
list previews, pending, context menus, list page
enter to add collection, lists page empty state
playable lists only, delete feature, bump
put fileListDownloaded back
better collection titles
improve collection claim details
fix horiz more icon
fix up channel page
style, copy, bump
refactor preview overlay properties,
fix reposts showing as floppydisk
add watch later toast,
small overlay properties on wunderbar results,
fix collection actions buttons
bump
cleanup
cleaning, refactoring
bump
preview thumb styling, cleanup
support discover page lists search
sync, bump
bump, fix sync more
enforce builtin order for now
new lists page empty state
try to indicate unpublished edits in lists
bump
fix autoplay and linting
consts, fix autoplay
bugs
fixes
cleanup
fix, bump
lists experimental ui, fixes
refactor listIndex out
hack in collection fallback thumb
bump
2021-02-06 08:03:51 +01:00
|
|
|
fetchCollectionListMine,
|
2019-10-01 06:53:33 +02:00
|
|
|
signIn,
|
2021-10-27 17:07:06 +02:00
|
|
|
isReloadRequired,
|
2019-10-11 02:37:18 +02:00
|
|
|
uploadCount,
|
2019-10-22 19:57:32 +02:00
|
|
|
history,
|
|
|
|
syncError,
|
2021-12-06 15:38:26 +01:00
|
|
|
syncIsLocked,
|
2022-05-18 11:13:14 +02:00
|
|
|
prefsReady,
|
2019-11-08 21:51:42 +01:00
|
|
|
language,
|
|
|
|
languages,
|
|
|
|
setLanguage,
|
2020-01-14 21:44:07 +01:00
|
|
|
rewards,
|
|
|
|
setReferrer,
|
2020-03-12 02:43:52 +01:00
|
|
|
isAuthenticated,
|
2021-01-21 20:50:51 +01:00
|
|
|
syncLoop,
|
2020-09-18 19:26:00 +02:00
|
|
|
currentModal,
|
2020-11-12 18:38:28 +01:00
|
|
|
syncFatalError,
|
2021-12-06 15:38:26 +01:00
|
|
|
myChannelClaimIds,
|
2022-02-18 14:14:54 +01:00
|
|
|
activeChannelClaim,
|
2021-02-09 17:05:56 +01:00
|
|
|
setIncognito,
|
2021-03-03 19:50:16 +01:00
|
|
|
fetchModBlockedList,
|
2022-03-18 01:58:06 +01:00
|
|
|
hasPremiumPlus,
|
2021-06-04 08:43:36 +02:00
|
|
|
fetchModAmIList,
|
2022-03-21 14:25:14 +01:00
|
|
|
homepageFetched,
|
2022-05-24 12:18:26 +02:00
|
|
|
defaultChannelClaim,
|
2022-05-18 11:13:14 +02:00
|
|
|
doOpenAnnouncements,
|
2022-05-18 11:19:51 +02:00
|
|
|
doSetLastViewedAnnouncement,
|
2022-05-24 12:18:26 +02:00
|
|
|
doSetDefaultChannel,
|
2019-09-23 03:56:43 +02:00
|
|
|
} = props;
|
2019-10-16 19:18:12 +02:00
|
|
|
|
2021-12-21 14:47:24 +01:00
|
|
|
const isMobile = useIsMobile();
|
2019-06-11 20:10:58 +02:00
|
|
|
const appRef = useRef();
|
|
|
|
const isEnhancedLayout = useKonamiListener();
|
2019-10-15 06:20:12 +02:00
|
|
|
const [hasSignedIn, setHasSignedIn] = useState(false);
|
2020-09-11 20:35:50 +02:00
|
|
|
const hasVerifiedEmail = user && Boolean(user.has_verified_email);
|
2019-08-14 18:28:13 +02:00
|
|
|
const isRewardApproved = user && user.is_reward_approved;
|
|
|
|
const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail);
|
|
|
|
const previousRewardApproved = usePrevious(isRewardApproved);
|
2021-11-09 09:08:13 +01:00
|
|
|
|
2022-03-02 15:44:01 +01:00
|
|
|
const [localeLangs, setLocaleLangs] = React.useState();
|
2022-03-21 14:25:14 +01:00
|
|
|
const [localeSwitchDismissed] = usePersistedState('locale-switch-dismissed', false);
|
2020-03-17 16:21:26 +01:00
|
|
|
const [lbryTvApiStatus, setLbryTvApiStatus] = useState(STATUS_OK);
|
2021-11-09 09:08:13 +01:00
|
|
|
|
2022-05-13 15:14:05 +02:00
|
|
|
const { pathname, hash, search, hostname } = location;
|
2021-11-22 15:30:43 +01:00
|
|
|
const [retryingSync, setRetryingSync] = useState(false);
|
2022-02-26 06:18:10 +01:00
|
|
|
const [langRenderKey, setLangRenderKey] = useState(0);
|
2021-08-05 18:24:43 +02:00
|
|
|
const [seenSunsestMessage, setSeenSunsetMessage] = usePersistedState('lbrytv-sunset', false);
|
2020-01-14 21:44:07 +01:00
|
|
|
// referral claiming
|
2021-03-03 19:50:16 +01:00
|
|
|
const referredRewardAvailable = rewards && rewards.some((reward) => reward.reward_type === REWARDS.TYPE_REFEREE);
|
2020-01-14 21:44:07 +01:00
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const rawReferrerParam = urlParams.get('r');
|
2021-08-05 18:24:43 +02:00
|
|
|
const fromLbrytvParam = urlParams.get('sunset');
|
2020-01-14 21:44:07 +01:00
|
|
|
const sanitizedReferrerParam = rawReferrerParam && rawReferrerParam.replace(':', '#');
|
2022-05-09 16:47:17 +02:00
|
|
|
const embedPath = pathname.startsWith(EMBED_PATH);
|
2022-03-21 14:25:14 +01:00
|
|
|
const shouldHideNag = embedPath || pathname.startsWith(`/$/${PAGES.AUTH_VERIFY}`);
|
2020-10-21 00:20:11 +02:00
|
|
|
const userId = user && user.id;
|
2021-12-06 15:38:26 +01:00
|
|
|
const hasMyChannels = myChannelClaimIds && myChannelClaimIds.length > 0;
|
|
|
|
const hasNoChannels = myChannelClaimIds && myChannelClaimIds.length === 0;
|
2021-04-06 21:15:08 +02:00
|
|
|
const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language];
|
2022-02-18 14:14:54 +01:00
|
|
|
const hasActiveChannelClaim = activeChannelClaim !== undefined;
|
2021-12-21 14:47:24 +01:00
|
|
|
const renderFiledrop = !isMobile && isAuthenticated;
|
2021-12-20 09:42:19 +01:00
|
|
|
const connectionStatus = useConnectionStatus();
|
2021-01-06 19:13:56 +01:00
|
|
|
|
2022-05-13 15:14:05 +02:00
|
|
|
const urlPath = pathname + hash;
|
2022-05-09 14:26:04 +02:00
|
|
|
const latestContentPath = urlPath.startsWith(LATEST_PATH);
|
|
|
|
const liveContentPath = urlPath.startsWith(LIVE_PATH);
|
2022-05-09 16:47:17 +02:00
|
|
|
const featureParam = urlParams.get('feature');
|
|
|
|
const embedLatestPath = embedPath && (featureParam === PAGES.LATEST || featureParam === PAGES.LIVE_NOW);
|
|
|
|
const isNewestPath = latestContentPath || liveContentPath || embedLatestPath;
|
2022-05-09 14:26:04 +02:00
|
|
|
|
|
|
|
let path;
|
|
|
|
if (isNewestPath) {
|
2022-05-09 16:47:17 +02:00
|
|
|
path = urlPath.replace(embedLatestPath ? EMBED_PATH : latestContentPath ? LATEST_PATH : LIVE_PATH, '');
|
2022-05-09 14:26:04 +02:00
|
|
|
} else {
|
|
|
|
// Remove the leading "/" added by the browser
|
|
|
|
path = urlPath.slice(1);
|
|
|
|
}
|
|
|
|
path = path.replace(/:/g, '#');
|
2022-05-13 15:14:05 +02:00
|
|
|
|
2022-05-09 14:26:04 +02:00
|
|
|
if (isNewestPath && !path.startsWith('@')) {
|
|
|
|
path = `@${path}`;
|
|
|
|
}
|
2022-05-13 15:14:05 +02:00
|
|
|
|
|
|
|
if (search && search.startsWith('?q=cache:')) {
|
|
|
|
generateGoogleCacheUrl(search, path);
|
|
|
|
}
|
|
|
|
|
2019-08-13 07:35:13 +02:00
|
|
|
let uri;
|
|
|
|
try {
|
2022-05-13 15:14:05 +02:00
|
|
|
uri = normalizeURI(path);
|
|
|
|
} catch (e) {
|
|
|
|
const match = path.match(/[#/:]/);
|
2019-08-13 07:35:13 +02:00
|
|
|
|
2022-05-13 15:14:05 +02:00
|
|
|
if (!path.startsWith('$/') && match && match.index) {
|
|
|
|
uri = `lbry://${path.slice(0, match.index)}`;
|
|
|
|
}
|
2020-02-21 21:44:58 +01:00
|
|
|
}
|
2021-01-21 20:50:51 +01:00
|
|
|
|
2021-11-22 15:30:43 +01:00
|
|
|
function getStatusNag() {
|
|
|
|
// Handle "offline" first. Everything else is meaningless if it's offline.
|
2021-12-20 09:42:19 +01:00
|
|
|
if (!connectionStatus.online) {
|
2021-11-22 15:30:43 +01:00
|
|
|
return <Nag type="helpful" message={__('You are offline. Check your internet connection.')} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only 1 nag is possible, so show the most important:
|
|
|
|
|
|
|
|
if (user === null) {
|
|
|
|
return <NagNoUser />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lbryTvApiStatus === STATUS_DEGRADED || lbryTvApiStatus === STATUS_FAILING) {
|
|
|
|
if (!shouldHideNag) {
|
|
|
|
return <NagDegradedPerformance onClose={() => setLbryTvApiStatus(STATUS_OK)} />;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (syncFatalError) {
|
|
|
|
if (!retryingSync) {
|
|
|
|
return (
|
|
|
|
<Nag
|
|
|
|
type="error"
|
|
|
|
message={__('Failed to synchronize settings. Wait a while before retrying.')}
|
|
|
|
actionText={__('Retry')}
|
|
|
|
onClick={() => {
|
|
|
|
syncLoop(true);
|
|
|
|
setRetryingSync(true);
|
|
|
|
setTimeout(() => setRetryingSync(false), 4000);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if (isReloadRequired) {
|
|
|
|
return (
|
|
|
|
<Nag
|
|
|
|
message={__('A new version of Odysee is available.')}
|
|
|
|
actionText={__('Refresh')}
|
|
|
|
onClick={() => window.location.reload()}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-03-02 15:44:01 +01:00
|
|
|
|
2022-03-21 14:25:14 +01:00
|
|
|
if (localeLangs && !embedPath && !localeSwitchDismissed && homepageFetched) {
|
2022-03-02 15:44:01 +01:00
|
|
|
const noLanguageSet = language === 'en' && languages.length === 1;
|
2022-03-21 14:25:14 +01:00
|
|
|
return <NagLocaleSwitch localeLangs={localeLangs} noLanguageSet={noLanguageSet} onFrontPage={pathname === '/'} />;
|
2022-03-02 15:44:01 +01:00
|
|
|
}
|
2021-11-22 15:30:43 +01:00
|
|
|
}
|
|
|
|
|
2020-10-21 00:20:11 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (userId) {
|
|
|
|
analytics.setUser(userId);
|
2021-11-24 21:25:22 +01:00
|
|
|
setSearchUserId(userId);
|
2020-10-21 00:20:11 +02:00
|
|
|
}
|
|
|
|
}, [userId]);
|
2020-02-21 21:44:58 +01:00
|
|
|
|
2021-12-06 15:38:26 +01:00
|
|
|
useEffect(() => {
|
|
|
|
if (syncIsLocked) {
|
|
|
|
const handleBeforeUnload = (event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
event.returnValue = __('There are unsaved settings. Exit the Settings Page to finalize them.');
|
|
|
|
};
|
|
|
|
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
|
|
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
|
|
}
|
|
|
|
}, [syncIsLocked]);
|
|
|
|
|
2019-10-11 02:37:18 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (!uploadCount) return;
|
2021-12-07 15:48:09 +01:00
|
|
|
|
|
|
|
const handleUnload = (event) => tusUnlockAndNotify();
|
2021-03-03 19:50:16 +01:00
|
|
|
const handleBeforeUnload = (event) => {
|
2019-10-11 02:37:18 +02:00
|
|
|
event.preventDefault();
|
2021-12-07 15:48:09 +01:00
|
|
|
event.returnValue = __('There are pending uploads.'); // without setting this to something it doesn't work
|
2019-10-11 02:37:18 +02:00
|
|
|
};
|
2021-12-07 15:48:09 +01:00
|
|
|
|
|
|
|
window.addEventListener('unload', handleUnload);
|
2019-10-11 02:37:18 +02:00
|
|
|
window.addEventListener('beforeunload', handleBeforeUnload);
|
2021-12-07 15:48:09 +01:00
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.removeEventListener('unload', handleUnload);
|
|
|
|
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
|
|
};
|
|
|
|
}, [uploadCount]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (!uploadCount) return;
|
|
|
|
|
|
|
|
const onStorageUpdate = (e) => tusHandleTabUpdates(e.key);
|
|
|
|
window.addEventListener('storage', onStorageUpdate);
|
|
|
|
|
|
|
|
return () => window.removeEventListener('storage', onStorageUpdate);
|
2019-10-11 02:37:18 +02:00
|
|
|
}, [uploadCount]);
|
|
|
|
|
2020-05-17 13:30:20 +02:00
|
|
|
// allows user to pause miniplayer using the spacebar without the page scrolling down
|
|
|
|
useEffect(() => {
|
2021-03-03 19:50:16 +01:00
|
|
|
const handleKeyPress = (e) => {
|
2020-05-17 13:30:20 +02:00
|
|
|
if (e.key === ' ' && e.target === document.body) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
window.addEventListener('keydown', handleKeyPress);
|
|
|
|
return () => window.removeEventListener('keydown', handleKeyPress);
|
2020-05-19 14:49:15 +02:00
|
|
|
}, []);
|
2020-05-17 13:30:20 +02:00
|
|
|
|
2020-01-14 21:44:07 +01:00
|
|
|
useEffect(() => {
|
|
|
|
if (referredRewardAvailable && sanitizedReferrerParam && isRewardApproved) {
|
|
|
|
setReferrer(sanitizedReferrerParam, true);
|
|
|
|
} else if (referredRewardAvailable && sanitizedReferrerParam) {
|
|
|
|
setReferrer(sanitizedReferrerParam, false);
|
|
|
|
}
|
2020-03-10 00:46:37 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2020-01-14 21:44:07 +01:00
|
|
|
}, [sanitizedReferrerParam, isRewardApproved, referredRewardAvailable]);
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
useEffect(() => {
|
2020-03-27 17:49:41 +01:00
|
|
|
const { current: wrapperElement } = appRef;
|
2020-02-06 19:49:05 +01:00
|
|
|
if (wrapperElement) {
|
|
|
|
ReactModal.setAppElement(wrapperElement);
|
|
|
|
}
|
2020-07-23 16:22:57 +02:00
|
|
|
|
2019-06-27 08:18:45 +02:00
|
|
|
// @if TARGET='app'
|
2020-07-23 16:22:57 +02:00
|
|
|
fetchChannelListMine(); // This is fetched after a user is signed in on web
|
wip
wip
wip - everything but publish, autoplay, and styling
collection publishing
add channel to collection publish
cleanup
wip
bump
clear mass add after success
move collection item management controls
redirect replace to published collection id
bump
playlist selector on create
bump
use new collection add ui element
bump
wip
gitignore
add content json
wip
bump
context add to playlist
basic collections page style pass wip
wip: edits, buttons, styles...
change fileAuthor to claimAuthor
update, pending bugfixes, delete modal progress, collection header, other bugfixes
bump
cleaning
show page bugfix
builtin collection headers
no playlists, no grid title
wip
style tweaks
use normal looking claim previews for collection tiles
add collection changes
style library previews
collection menulist for delete/view on library
delete modal works for unpublished
rearrange collection publish tabs
clean up collection publishing and items
show on odysee
begin collectoin edit header and css renaming
better thumbnails
bump
fix collection publish redirect
view collection in menu does something
copy and thumbs
list previews, pending, context menus, list page
enter to add collection, lists page empty state
playable lists only, delete feature, bump
put fileListDownloaded back
better collection titles
improve collection claim details
fix horiz more icon
fix up channel page
style, copy, bump
refactor preview overlay properties,
fix reposts showing as floppydisk
add watch later toast,
small overlay properties on wunderbar results,
fix collection actions buttons
bump
cleanup
cleaning, refactoring
bump
preview thumb styling, cleanup
support discover page lists search
sync, bump
bump, fix sync more
enforce builtin order for now
new lists page empty state
try to indicate unpublished edits in lists
bump
fix autoplay and linting
consts, fix autoplay
bugs
fixes
cleanup
fix, bump
lists experimental ui, fixes
refactor listIndex out
hack in collection fallback thumb
bump
2021-02-06 08:03:51 +01:00
|
|
|
fetchCollectionListMine();
|
2019-06-27 08:18:45 +02:00
|
|
|
// @endif
|
2022-01-19 14:27:22 +01:00
|
|
|
}, [appRef, fetchChannelListMine, fetchCollectionListMine]);
|
2018-10-18 18:45:24 +02:00
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
useEffect(() => {
|
2018-10-18 18:45:24 +02:00
|
|
|
// $FlowFixMe
|
2019-11-22 22:13:00 +01:00
|
|
|
document.documentElement.setAttribute('theme', theme);
|
2019-06-11 20:10:58 +02:00
|
|
|
}, [theme]);
|
2018-11-07 17:03:42 +01:00
|
|
|
|
2022-02-18 18:03:15 +01:00
|
|
|
useEffect(() => {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.body.style.overflowY = currentModal ? 'hidden' : '';
|
|
|
|
}, [currentModal]);
|
|
|
|
|
2019-11-08 21:51:42 +01:00
|
|
|
useEffect(() => {
|
2022-05-04 14:34:31 +02:00
|
|
|
if (hasNoChannels) {
|
2021-02-09 17:05:56 +01:00
|
|
|
setIncognito(true);
|
|
|
|
}
|
2021-03-03 19:50:16 +01:00
|
|
|
|
|
|
|
if (hasMyChannels) {
|
|
|
|
fetchModBlockedList();
|
2021-06-04 08:43:36 +02:00
|
|
|
fetchModAmIList();
|
2022-05-24 12:18:26 +02:00
|
|
|
if (activeChannelClaim && !defaultChannelClaim) doSetDefaultChannel(activeChannelClaim.claim_id);
|
2021-03-03 19:50:16 +01:00
|
|
|
}
|
2022-03-02 15:44:01 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2022-05-04 14:34:31 +02:00
|
|
|
}, [hasMyChannels, hasNoChannels, hasActiveChannelClaim, setIncognito]);
|
2021-02-09 17:05:56 +01:00
|
|
|
|
2021-07-16 09:22:54 +02:00
|
|
|
useEffect(() => {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.documentElement.setAttribute('lang', language);
|
|
|
|
}, [language]);
|
|
|
|
|
2021-02-09 17:05:56 +01:00
|
|
|
useEffect(() => {
|
2019-11-08 21:51:42 +01:00
|
|
|
if (!languages.includes(language)) {
|
|
|
|
setLanguage(language);
|
2021-07-16 19:51:08 +02:00
|
|
|
|
|
|
|
if (document && document.documentElement && LANGUAGES[language].length >= 3) {
|
|
|
|
document.documentElement.dir = LANGUAGES[language][2];
|
|
|
|
}
|
2019-11-08 21:51:42 +01:00
|
|
|
}
|
2020-03-10 00:46:37 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2019-11-08 21:51:42 +01:00
|
|
|
}, [language, languages]);
|
|
|
|
|
2021-04-06 21:15:08 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (shouldMigrateLanguage) {
|
|
|
|
setLanguage(shouldMigrateLanguage);
|
|
|
|
}
|
|
|
|
}, [shouldMigrateLanguage, setLanguage]);
|
|
|
|
|
2019-08-14 18:28:13 +02:00
|
|
|
useEffect(() => {
|
2019-08-15 05:09:34 +02:00
|
|
|
// Check that previousHasVerifiedEmail was not undefined instead of just not truthy
|
|
|
|
// This ensures we don't fire the emailVerified event on the initial user fetch
|
2019-09-26 18:07:11 +02:00
|
|
|
if (previousHasVerifiedEmail === false && hasVerifiedEmail) {
|
2019-08-14 18:28:13 +02:00
|
|
|
analytics.emailVerifiedEvent();
|
|
|
|
}
|
2019-10-01 06:53:33 +02:00
|
|
|
}, [previousHasVerifiedEmail, hasVerifiedEmail, signIn]);
|
2019-08-14 18:28:13 +02:00
|
|
|
|
|
|
|
useEffect(() => {
|
2019-09-26 18:07:11 +02:00
|
|
|
if (previousRewardApproved === false && isRewardApproved) {
|
2019-08-14 18:28:13 +02:00
|
|
|
analytics.rewardEligibleEvent();
|
|
|
|
}
|
|
|
|
}, [previousRewardApproved, isRewardApproved]);
|
2019-07-22 04:28:49 +02:00
|
|
|
|
2021-10-13 17:04:03 +02:00
|
|
|
// Load IMA3 SDK for aniview
|
2021-12-15 19:29:06 +01:00
|
|
|
// useEffect(() => {
|
|
|
|
// if (!isAuthenticated && SHOW_ADS) {
|
|
|
|
// const script = document.createElement('script');
|
|
|
|
// script.src = imaLibraryPath;
|
|
|
|
// script.async = true;
|
|
|
|
// // $FlowFixMe
|
|
|
|
// document.body.appendChild(script);
|
|
|
|
// return () => {
|
|
|
|
// // $FlowFixMe
|
|
|
|
// document.body.removeChild(script);
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
// }, []);
|
2021-08-19 01:30:07 +02:00
|
|
|
|
2021-12-09 21:14:11 +01:00
|
|
|
// add OneTrust script
|
2021-11-23 16:21:33 +01:00
|
|
|
useEffect(() => {
|
2021-12-09 21:14:11 +01:00
|
|
|
// don't add script for embedded content
|
2021-11-26 15:24:51 +01:00
|
|
|
function inIframe() {
|
|
|
|
try {
|
|
|
|
return window.self !== window.top;
|
|
|
|
} catch (e) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-17 07:12:16 +01:00
|
|
|
if (inIframe() || !locale || !locale.gdpr_required) {
|
2021-11-26 15:24:51 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-14 19:20:44 +01:00
|
|
|
// $FlowFixMe
|
2022-05-13 15:14:05 +02:00
|
|
|
const useProductionOneTrust = process.env.NODE_ENV === 'production' && hostname === 'odysee.com';
|
2021-12-14 19:20:44 +01:00
|
|
|
|
2021-11-23 16:21:33 +01:00
|
|
|
const script = document.createElement('script');
|
2021-12-09 18:59:15 +01:00
|
|
|
script.src = oneTrustScriptSrc;
|
|
|
|
script.setAttribute('charset', 'UTF-8');
|
2021-12-14 19:20:44 +01:00
|
|
|
if (useProductionOneTrust) {
|
2021-12-16 22:05:29 +01:00
|
|
|
script.setAttribute('data-domain-script', '8a792d84-50a5-4b69-b080-6954ad4d4606');
|
2021-12-14 19:20:44 +01:00
|
|
|
} else {
|
|
|
|
script.setAttribute('data-domain-script', '8a792d84-50a5-4b69-b080-6954ad4d4606-test');
|
|
|
|
}
|
2021-11-23 16:21:33 +01:00
|
|
|
|
2021-12-09 21:14:11 +01:00
|
|
|
const secondScript = document.createElement('script');
|
|
|
|
// OneTrust asks to add this
|
|
|
|
secondScript.innerHTML = 'function OptanonWrapper() { }';
|
2021-11-23 23:26:23 +01:00
|
|
|
|
2022-03-17 07:12:16 +01:00
|
|
|
// $FlowFixMe
|
|
|
|
document.head.appendChild(script);
|
|
|
|
// $FlowFixMe
|
|
|
|
document.head.appendChild(secondScript);
|
2021-11-23 16:21:33 +01:00
|
|
|
|
|
|
|
return () => {
|
2021-12-02 19:22:51 +01:00
|
|
|
try {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.head.removeChild(script);
|
|
|
|
// $FlowFixMe
|
2021-12-09 21:14:11 +01:00
|
|
|
document.head.removeChild(secondScript);
|
2021-12-02 19:22:51 +01:00
|
|
|
} catch (err) {
|
2022-03-02 15:44:01 +01:00
|
|
|
// eslint-disable-next-line no-console
|
2022-03-17 07:12:16 +01:00
|
|
|
// console.log(err); <-- disabling this ... it's clogging up Sentry logs.
|
2021-12-02 19:22:51 +01:00
|
|
|
}
|
2021-11-23 16:21:33 +01:00
|
|
|
};
|
2022-03-17 07:12:16 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps, (one time after locale is fetched)
|
|
|
|
}, [locale]);
|
|
|
|
|
2022-05-18 11:13:14 +02:00
|
|
|
useEffect(() => {
|
2022-03-17 07:12:16 +01:00
|
|
|
if (locale) {
|
|
|
|
const countryCode = locale.country;
|
|
|
|
const langs = getLanguagesForCountry(countryCode) || [];
|
|
|
|
const supportedLangs = langs.filter((lang) => lang !== 'en' && SUPPORTED_LANGUAGES[lang]);
|
|
|
|
|
|
|
|
if (supportedLangs.length > 0) {
|
|
|
|
setLocaleLangs(supportedLangs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [locale]);
|
2021-11-23 16:21:33 +01:00
|
|
|
|
2020-09-04 17:02:30 +02:00
|
|
|
// ready for sync syncs, however after signin when hasVerifiedEmail, that syncs too.
|
2019-12-21 19:43:42 +01:00
|
|
|
useEffect(() => {
|
2020-09-09 19:37:55 +02:00
|
|
|
// signInSyncPref is cleared after sharedState loop.
|
2021-01-21 20:50:51 +01:00
|
|
|
const syncLoopWithoutInterval = () => syncLoop(true);
|
2021-11-15 04:28:30 +01:00
|
|
|
if (hasSignedIn && hasVerifiedEmail) {
|
2020-09-11 20:35:50 +02:00
|
|
|
// In case we are syncing.
|
2021-01-21 20:50:51 +01:00
|
|
|
syncLoop();
|
|
|
|
window.addEventListener('focus', syncLoopWithoutInterval);
|
2020-09-04 17:02:30 +02:00
|
|
|
}
|
2021-01-21 20:50:51 +01:00
|
|
|
return () => {
|
|
|
|
window.removeEventListener('focus', syncLoopWithoutInterval);
|
|
|
|
};
|
2021-11-15 04:28:30 +01:00
|
|
|
}, [hasSignedIn, hasVerifiedEmail, syncLoop]);
|
2019-12-11 21:09:27 +01:00
|
|
|
|
2019-10-22 19:57:32 +02:00
|
|
|
useEffect(() => {
|
2020-09-18 19:26:00 +02:00
|
|
|
if (syncError && isAuthenticated && !pathname.includes(PAGES.AUTH_WALLET_PASSWORD) && !currentModal) {
|
2020-09-18 17:16:49 +02:00
|
|
|
history.push(`/$/${PAGES.AUTH_WALLET_PASSWORD}?redirect=${pathname}`);
|
2019-10-22 22:43:51 +02:00
|
|
|
}
|
2020-03-10 00:46:37 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2020-03-12 02:43:52 +01:00
|
|
|
}, [syncError, pathname, isAuthenticated]);
|
2019-10-22 19:57:32 +02:00
|
|
|
|
2022-05-18 11:13:14 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (prefsReady) {
|
|
|
|
doOpenAnnouncements();
|
|
|
|
}
|
|
|
|
}, [prefsReady]);
|
|
|
|
|
2022-05-18 11:19:51 +02:00
|
|
|
useEffect(() => {
|
|
|
|
window.clearLastViewedAnnouncement = () => {
|
|
|
|
console.log('Clearing history. Please wait ...');
|
|
|
|
doSetLastViewedAnnouncement('');
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
2020-09-04 17:02:30 +02:00
|
|
|
// Keep this at the end to ensure initial setup effects are run first
|
|
|
|
useEffect(() => {
|
|
|
|
if (!hasSignedIn && hasVerifiedEmail) {
|
|
|
|
signIn();
|
|
|
|
setHasSignedIn(true);
|
|
|
|
}
|
|
|
|
}, [hasVerifiedEmail, signIn, hasSignedIn]);
|
|
|
|
|
2020-12-10 23:31:20 +01:00
|
|
|
useDegradedPerformance(setLbryTvApiStatus, user);
|
2020-03-12 18:47:40 +01:00
|
|
|
|
2022-04-05 14:28:51 +02:00
|
|
|
useAdOutbrain(Boolean(hasPremiumPlus), isAuthenticated, history?.location?.pathname);
|
2022-03-18 01:58:06 +01:00
|
|
|
|
2022-02-26 06:18:10 +01:00
|
|
|
useEffect(() => {
|
|
|
|
// When language is changed or translations are fetched, we render.
|
|
|
|
setLangRenderKey(Date.now());
|
|
|
|
}, [language, languages]);
|
|
|
|
|
2019-11-14 16:25:01 +01:00
|
|
|
// Require an internal-api user on lbry.tv
|
|
|
|
// This also prevents the site from loading in the un-authed state while we wait for internal-apis to return for the first time
|
|
|
|
// It's not needed on desktop since there is no un-authed state
|
2021-06-18 00:52:21 +02:00
|
|
|
if (user === undefined) {
|
2020-10-28 17:02:06 +01:00
|
|
|
return (
|
|
|
|
<div className="main--empty">
|
|
|
|
<Spinner delayed />
|
|
|
|
</div>
|
|
|
|
);
|
2019-12-05 17:30:48 +01:00
|
|
|
}
|
2019-08-06 18:00:31 +02:00
|
|
|
|
2021-12-20 09:42:19 +01:00
|
|
|
if (connectionStatus.online && lbryTvApiStatus === STATUS_DOWN) {
|
2021-11-22 15:30:43 +01:00
|
|
|
// TODO: Rename `SyncFatalError` since it has nothing to do with syncing.
|
2021-03-16 22:21:47 +01:00
|
|
|
return (
|
2021-06-11 08:06:29 +02:00
|
|
|
<React.Suspense fallback={null}>
|
2021-11-09 09:08:13 +01:00
|
|
|
<SyncFatalError lbryTvApiStatus={lbryTvApiStatus} />
|
2021-06-11 08:06:29 +02:00
|
|
|
</React.Suspense>
|
2021-03-16 22:21:47 +01:00
|
|
|
);
|
2020-11-12 18:38:28 +01:00
|
|
|
}
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
return (
|
2022-05-13 15:14:05 +02:00
|
|
|
<div className={MAIN_WRAPPER_CLASS} ref={appRef} key={langRenderKey}>
|
|
|
|
{lbryTvApiStatus === STATUS_DOWN ? (
|
2021-10-26 08:15:08 +02:00
|
|
|
<Yrbl
|
|
|
|
className="main--empty"
|
2021-11-03 20:47:19 +01:00
|
|
|
title={__('odysee.com is currently down')}
|
2021-10-26 08:15:08 +02:00
|
|
|
subtitle={__('My wheel broke, but the good news is that someone from LBRY is working on it.')}
|
|
|
|
/>
|
2020-03-17 16:21:26 +01:00
|
|
|
) : (
|
2020-02-21 22:05:20 +01:00
|
|
|
<React.Fragment>
|
2022-05-09 16:47:17 +02:00
|
|
|
<Router uri={uri} embedLatestPath={embedLatestPath} />
|
2021-10-26 08:15:08 +02:00
|
|
|
<ModalRouter />
|
2022-05-13 15:14:05 +02:00
|
|
|
|
2021-10-26 08:15:08 +02:00
|
|
|
<React.Suspense fallback={null}>{renderFiledrop && <FileDrop />}</React.Suspense>
|
2022-03-15 17:28:55 +01:00
|
|
|
|
2022-03-15 17:47:36 +01:00
|
|
|
<FileRenderFloating />
|
2022-03-15 17:28:55 +01:00
|
|
|
|
2021-06-11 08:06:29 +02:00
|
|
|
<React.Suspense fallback={null}>
|
|
|
|
{isEnhancedLayout && <Yrbl className="yrbl--enhanced" />}
|
|
|
|
|
|
|
|
<YoutubeWelcome />
|
|
|
|
{!shouldHideNag && <NagContinueFirstRun />}
|
2021-08-05 18:35:52 +02:00
|
|
|
{fromLbrytvParam && !seenSunsestMessage && !shouldHideNag && (
|
2021-08-05 18:24:43 +02:00
|
|
|
<NagSunset email={hasVerifiedEmail} onClose={() => setSeenSunsetMessage(true)} />
|
|
|
|
)}
|
2021-11-22 15:30:43 +01:00
|
|
|
{getStatusNag()}
|
2021-06-11 08:06:29 +02:00
|
|
|
</React.Suspense>
|
2020-02-21 22:05:20 +01:00
|
|
|
</React.Fragment>
|
2020-02-21 21:44:58 +01:00
|
|
|
)}
|
2019-06-11 20:10:58 +02:00
|
|
|
</div>
|
|
|
|
);
|
2017-05-04 05:44:08 +02:00
|
|
|
}
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2019-08-13 07:35:13 +02:00
|
|
|
export default withRouter(App);
|