Remove 'web' preprocessor

This commit is contained in:
infinite-persistence 2021-11-09 16:08:13 +08:00
parent 45ad08ec32
commit 9fc417edfa
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -20,8 +20,6 @@ import REWARDS from 'rewards';
import usePersistedState from 'effects/use-persisted-state'; import usePersistedState from 'effects/use-persisted-state';
import Spinner from 'component/spinner'; import Spinner from 'component/spinner';
import LANGUAGES from 'constants/languages'; import LANGUAGES from 'constants/languages';
// @if TARGET='web'
import YoutubeWelcome from 'web/component/youtubeReferralWelcome'; import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
import { import {
useDegradedPerformance, useDegradedPerformance,
@ -30,22 +28,17 @@ import {
STATUS_FAILING, STATUS_FAILING,
STATUS_DOWN, STATUS_DOWN,
} from 'web/effects/use-degraded-performance'; } from 'web/effects/use-degraded-performance';
// @endif
import LANGUAGE_MIGRATIONS from 'constants/language-migrations'; import LANGUAGE_MIGRATIONS from 'constants/language-migrations';
const FileDrop = lazyImport(() => import('component/fileDrop' /* webpackChunkName: "fileDrop" */)); const FileDrop = lazyImport(() => import('component/fileDrop' /* webpackChunkName: "fileDrop" */));
const NagContinueFirstRun = lazyImport(() => import('component/nagContinueFirstRun' /* webpackChunkName: "nagCFR" */)); const NagContinueFirstRun = lazyImport(() => import('component/nagContinueFirstRun' /* webpackChunkName: "nagCFR" */));
const OpenInAppLink = lazyImport(() => import('web/component/openInAppLink' /* webpackChunkName: "openInAppLink" */)); const OpenInAppLink = lazyImport(() => import('web/component/openInAppLink' /* webpackChunkName: "openInAppLink" */));
// @if TARGET='web'
const NagDataCollection = lazyImport(() => import('web/component/nag-data-collection' /* webpackChunkName: "nagDC" */)); const NagDataCollection = lazyImport(() => import('web/component/nag-data-collection' /* webpackChunkName: "nagDC" */));
const NagDegradedPerformance = lazyImport(() => const NagDegradedPerformance = lazyImport(() =>
import('web/component/nag-degraded-performance' /* webpackChunkName: "NagDegradedPerformance" */) import('web/component/nag-degraded-performance' /* webpackChunkName: "NagDegradedPerformance" */)
); );
const NagNoUser = lazyImport(() => import('web/component/nag-no-user' /* webpackChunkName: "nag-no-user" */)); const NagNoUser = lazyImport(() => import('web/component/nag-no-user' /* webpackChunkName: "nag-no-user" */));
const NagSunset = lazyImport(() => import('web/component/nag-sunset' /* webpackChunkName: "nag-sunset" */)); const NagSunset = lazyImport(() => import('web/component/nag-sunset' /* webpackChunkName: "nag-sunset" */));
// @endif
const SyncFatalError = lazyImport(() => import('component/syncFatalError' /* webpackChunkName: "syncFatalError" */)); const SyncFatalError = lazyImport(() => import('component/syncFatalError' /* webpackChunkName: "syncFatalError" */));
// **************************************************************************** // ****************************************************************************
@ -150,10 +143,10 @@ function App(props: Props) {
const isRewardApproved = user && user.is_reward_approved; const isRewardApproved = user && user.is_reward_approved;
const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail); const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail);
const previousRewardApproved = usePrevious(isRewardApproved); const previousRewardApproved = usePrevious(isRewardApproved);
// @if TARGET='web'
const [showAnalyticsNag, setShowAnalyticsNag] = usePersistedState('analytics-nag', true); const [showAnalyticsNag, setShowAnalyticsNag] = usePersistedState('analytics-nag', true);
const [lbryTvApiStatus, setLbryTvApiStatus] = useState(STATUS_OK); const [lbryTvApiStatus, setLbryTvApiStatus] = useState(STATUS_OK);
// @endif
const { pathname, hash, search } = props.location; const { pathname, hash, search } = props.location;
const [upgradeNagClosed, setUpgradeNagClosed] = useState(false); const [upgradeNagClosed, setUpgradeNagClosed] = useState(false);
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false); const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
@ -183,12 +176,10 @@ function App(props: Props) {
uri = newpath + hash; uri = newpath + hash;
} catch (e) {} } catch (e) {}
// @if TARGET='web'
function handleAnalyticsDismiss() { function handleAnalyticsDismiss() {
setShowAnalyticsNag(false); setShowAnalyticsNag(false);
} }
// @endif
useEffect(() => { useEffect(() => {
if (userId) { if (userId) {
analytics.setUser(userId); analytics.setUser(userId);
@ -310,7 +301,6 @@ function App(props: Props) {
}, [previousRewardApproved, isRewardApproved]); }, [previousRewardApproved, isRewardApproved]);
// Load IMA3 SDK for aniview // Load IMA3 SDK for aniview
// @if TARGET='web'
useEffect(() => { useEffect(() => {
const script = document.createElement('script'); const script = document.createElement('script');
script.src = imaLibraryPath; script.src = imaLibraryPath;
@ -322,7 +312,6 @@ function App(props: Props) {
document.body.removeChild(script); document.body.removeChild(script);
}; };
}, []); }, []);
// @endif
// @if TARGET='app' // @if TARGET='app'
useEffect(() => { useEffect(() => {
@ -343,15 +332,11 @@ function App(props: Props) {
if (readyForSync && hasVerifiedEmail) { if (readyForSync && hasVerifiedEmail) {
// In case we are syncing. // In case we are syncing.
syncLoop(); syncLoop();
// @if TARGET='web'
window.addEventListener('focus', syncLoopWithoutInterval); window.addEventListener('focus', syncLoopWithoutInterval);
// @endif
} }
// @if TARGET='web'
return () => { return () => {
window.removeEventListener('focus', syncLoopWithoutInterval); window.removeEventListener('focus', syncLoopWithoutInterval);
}; };
// @endif
}, [readyForSync, hasVerifiedEmail, syncLoop]); }, [readyForSync, hasVerifiedEmail, syncLoop]);
// We know someone is logging in or not when we get their user object // We know someone is logging in or not when we get their user object
@ -389,11 +374,8 @@ function App(props: Props) {
} }
}, [sidebarOpen, isPersonalized, resolvedSubscriptions, subscriptions, resolveUris, setResolvedSubscriptions]); }, [sidebarOpen, isPersonalized, resolvedSubscriptions, subscriptions, resolveUris, setResolvedSubscriptions]);
// @if TARGET='web'
useDegradedPerformance(setLbryTvApiStatus, user); useDegradedPerformance(setLbryTvApiStatus, user);
// @endif
// @if TARGET='web'
// Require an internal-api user on lbry.tv // 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 // 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 // It's not needed on desktop since there is no un-authed state
@ -404,16 +386,11 @@ function App(props: Props) {
</div> </div>
); );
} }
// @endif
if (syncFatalError) { if (syncFatalError) {
return ( return (
<React.Suspense fallback={null}> <React.Suspense fallback={null}>
<SyncFatalError <SyncFatalError lbryTvApiStatus={lbryTvApiStatus} />
// @if TARGET='web'
lbryTvApiStatus={lbryTvApiStatus}
// @endif
/>
</React.Suspense> </React.Suspense>
); );
} }
@ -455,7 +432,6 @@ function App(props: Props) {
)} )}
{/* @endif */} {/* @endif */}
{/* @if TARGET='web' */}
<YoutubeWelcome /> <YoutubeWelcome />
{!SIMPLE_SITE && !shouldHideNag && <OpenInAppLink uri={uri} />} {!SIMPLE_SITE && !shouldHideNag && <OpenInAppLink uri={uri} />}
{!shouldHideNag && <NagContinueFirstRun />} {!shouldHideNag && <NagContinueFirstRun />}
@ -469,7 +445,6 @@ function App(props: Props) {
<NagDataCollection onClose={handleAnalyticsDismiss} /> <NagDataCollection onClose={handleAnalyticsDismiss} />
)} )}
{user === null && <NagNoUser />} {user === null && <NagNoUser />}
{/* @endif */}
</React.Suspense> </React.Suspense>
{isReloadRequired && ( {isReloadRequired && (