app works when id api fails
This commit is contained in:
parent
701ec0a473
commit
2268ab01fb
9 changed files with 73 additions and 27 deletions
|
@ -30,6 +30,7 @@ import OpenInAppLink from 'web/component/openInAppLink';
|
||||||
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
|
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
|
||||||
import NagDegradedPerformance from 'web/component/nag-degraded-performance';
|
import NagDegradedPerformance from 'web/component/nag-degraded-performance';
|
||||||
import NagDataCollection from 'web/component/nag-data-collection';
|
import NagDataCollection from 'web/component/nag-data-collection';
|
||||||
|
import NagNoUser from 'web/component/nag-no-user';
|
||||||
import {
|
import {
|
||||||
useDegradedPerformance,
|
useDegradedPerformance,
|
||||||
STATUS_OK,
|
STATUS_OK,
|
||||||
|
@ -363,7 +364,7 @@ function App(props: Props) {
|
||||||
// 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
|
||||||
if (!user) {
|
if (user === undefined) {
|
||||||
return (
|
return (
|
||||||
<div className="main--empty">
|
<div className="main--empty">
|
||||||
<Spinner delayed />
|
<Spinner delayed />
|
||||||
|
@ -428,6 +429,7 @@ function App(props: Props) {
|
||||||
{!SIMPLE_SITE && lbryTvApiStatus === STATUS_OK && showAnalyticsNag && !shouldHideNag && (
|
{!SIMPLE_SITE && lbryTvApiStatus === STATUS_OK && showAnalyticsNag && !shouldHideNag && (
|
||||||
<NagDataCollection onClose={handleAnalyticsDismiss} />
|
<NagDataCollection onClose={handleAnalyticsDismiss} />
|
||||||
)}
|
)}
|
||||||
|
{user === null && <NagNoUser />}
|
||||||
{/* @endif */}
|
{/* @endif */}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import Button from './view';
|
import Button from './view';
|
||||||
import React, { forwardRef } from 'react';
|
import React, { forwardRef } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = (state) => ({
|
||||||
pathname: state.router.location.pathname,
|
pathname: state.router.location.pathname,
|
||||||
emailVerified: selectUserVerifiedEmail(state),
|
emailVerified: selectUserVerifiedEmail(state),
|
||||||
|
user: selectUser(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const ConnectedButton = connect(mapStateToProps)(Button);
|
const ConnectedButton = connect(mapStateToProps)(Button);
|
||||||
|
|
|
@ -38,6 +38,7 @@ type Props = {
|
||||||
myref: any,
|
myref: any,
|
||||||
dispatch: any,
|
dispatch: any,
|
||||||
'aria-label'?: string,
|
'aria-label'?: string,
|
||||||
|
user: ?User,
|
||||||
};
|
};
|
||||||
|
|
||||||
// use forwardRef to allow consumers to pass refs to the button content if they want to
|
// use forwardRef to allow consumers to pass refs to the button content if they want to
|
||||||
|
@ -69,10 +70,14 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
myref,
|
myref,
|
||||||
dispatch, // <button> doesn't know what to do with dispatch
|
dispatch, // <button> doesn't know what to do with dispatch
|
||||||
pathname,
|
pathname,
|
||||||
|
user,
|
||||||
authSrc,
|
authSrc,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
console.log('user', user);
|
||||||
|
const disable = disabled || (user === null && requiresAuth);
|
||||||
|
|
||||||
const combinedClassName = classnames(
|
const combinedClassName = classnames(
|
||||||
'button',
|
'button',
|
||||||
button
|
button
|
||||||
|
@ -82,7 +87,7 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
'button--alt': button === 'alt',
|
'button--alt': button === 'alt',
|
||||||
'button--inverse': button === 'inverse',
|
'button--inverse': button === 'inverse',
|
||||||
'button--close': button === 'close',
|
'button--close': button === 'close',
|
||||||
'button--disabled': disabled,
|
'button--disabled': disable,
|
||||||
'button--link': button === 'link',
|
'button--link': button === 'link',
|
||||||
}
|
}
|
||||||
: 'button--no-style',
|
: 'button--no-style',
|
||||||
|
@ -184,12 +189,12 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
return (
|
return (
|
||||||
<NavLink
|
<NavLink
|
||||||
exact
|
exact
|
||||||
onClick={e => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
to={redirectUrl}
|
to={redirectUrl}
|
||||||
title={title || defaultTooltip}
|
title={title || defaultTooltip}
|
||||||
disabled={disabled}
|
disabled={disable}
|
||||||
className={combinedClassName}
|
className={combinedClassName}
|
||||||
activeClassName={activeClass}
|
activeClassName={activeClass}
|
||||||
>
|
>
|
||||||
|
@ -203,8 +208,8 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
exact
|
exact
|
||||||
to={path}
|
to={path}
|
||||||
title={title || defaultTooltip}
|
title={title || defaultTooltip}
|
||||||
disabled={disabled}
|
disabled={disable}
|
||||||
onClick={e => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (onClick) {
|
if (onClick) {
|
||||||
onClick();
|
onClick();
|
||||||
|
@ -222,13 +227,13 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
title={title || defaultTooltip}
|
title={title || defaultTooltip}
|
||||||
aria-label={description || label || title}
|
aria-label={description || label || title}
|
||||||
className={combinedClassName}
|
className={combinedClassName}
|
||||||
onClick={e => {
|
onClick={(e) => {
|
||||||
if (onClick) {
|
if (onClick) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onClick(e);
|
onClick(e);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={disabled}
|
disabled={disable}
|
||||||
type={type}
|
type={type}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
>
|
>
|
||||||
|
|
|
@ -170,8 +170,14 @@ const Header = (props: Props) => {
|
||||||
|
|
||||||
const loginButtons = (
|
const loginButtons = (
|
||||||
<div className="header__auth-buttons">
|
<div className="header__auth-buttons">
|
||||||
<Button navigate={`/$/${PAGES.AUTH_SIGNIN}`} button="link" label={__('Log In')} className="mobile-hidden" />
|
<Button
|
||||||
<Button navigate={`/$/${PAGES.AUTH}`} button="primary" label={__('Sign Up')} />
|
navigate={`/$/${PAGES.AUTH_SIGNIN}`}
|
||||||
|
button="link"
|
||||||
|
label={__('Log In')}
|
||||||
|
className="mobile-hidden"
|
||||||
|
disabled={user === null}
|
||||||
|
/>
|
||||||
|
<Button navigate={`/$/${PAGES.AUTH}`} button="primary" label={__('Sign Up')} disabled={user === null} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,13 @@ function SideNavigation(props: Props) {
|
||||||
Sign up to earn %lbc% for you and your favorite creators.
|
Sign up to earn %lbc% for you and your favorite creators.
|
||||||
</I18nMessage>
|
</I18nMessage>
|
||||||
</span>
|
</span>
|
||||||
<Button button="secondary" label={__('Sign Up')} navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`} />
|
<Button
|
||||||
|
button="secondary"
|
||||||
|
label={__('Sign Up')}
|
||||||
|
navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`}
|
||||||
|
disabled={user === null}
|
||||||
|
/>{' '}
|
||||||
|
//
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -503,17 +503,18 @@ export function doAnalyticsBuffer(uri, bufferData) {
|
||||||
const fileSize = source.size; // size in bytes
|
const fileSize = source.size; // size in bytes
|
||||||
const fileSizeInBits = fileSize * 8;
|
const fileSizeInBits = fileSize * 8;
|
||||||
const bitRate = parseInt(fileSizeInBits / fileDurationInSeconds);
|
const bitRate = parseInt(fileSizeInBits / fileDurationInSeconds);
|
||||||
const userId = user.id.toString();
|
const userId = user && user.id.toString();
|
||||||
|
if (userId) {
|
||||||
analytics.videoBufferEvent(claim, {
|
analytics.videoBufferEvent(claim, {
|
||||||
timeAtBuffer,
|
timeAtBuffer,
|
||||||
bufferDuration,
|
bufferDuration,
|
||||||
bitRate,
|
bitRate,
|
||||||
userId,
|
userId,
|
||||||
duration: fileDurationInSeconds,
|
duration: fileDurationInSeconds,
|
||||||
playerPoweredBy: bufferData.playerPoweredBy,
|
playerPoweredBy: bufferData.playerPoweredBy,
|
||||||
readyState: bufferData.readyState,
|
readyState: bufferData.readyState,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ export function doInstallNewWithParams(
|
||||||
|
|
||||||
function checkAuthBusy() {
|
function checkAuthBusy() {
|
||||||
let time = Date.now();
|
let time = Date.now();
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
(function waitForAuth() {
|
(function waitForAuth() {
|
||||||
try {
|
try {
|
||||||
sessionStorage.setItem('test', 'available');
|
sessionStorage.setItem('test', 'available');
|
||||||
|
|
25
web/component/nag-no-user.jsx
Normal file
25
web/component/nag-no-user.jsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// @flow
|
||||||
|
import { SITE_NAME } from 'config';
|
||||||
|
import React from 'react';
|
||||||
|
import Nag from 'component/common/nag';
|
||||||
|
import I18nMessage from 'component/i18nMessage';
|
||||||
|
|
||||||
|
export default function NagNoUser() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Nag
|
||||||
|
type="error"
|
||||||
|
message={
|
||||||
|
<I18nMessage
|
||||||
|
tokens={{
|
||||||
|
SITE_NAME,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
%DOMAIN% id not available. Account functions will be unavailable. Refresh to try again.
|
||||||
|
</I18nMessage>
|
||||||
|
}
|
||||||
|
actionText={__('Refresh')}
|
||||||
|
onClick={() => window.location.reload()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ export const STATUS_DOWN = 'down';
|
||||||
const getParams = (user) => {
|
const getParams = (user) => {
|
||||||
const headers = {};
|
const headers = {};
|
||||||
const token = getAuthToken();
|
const token = getAuthToken();
|
||||||
if (token && user.has_verified_email) {
|
if (token && user && user.has_verified_email) {
|
||||||
headers[X_LBRY_AUTH_TOKEN] = token;
|
headers[X_LBRY_AUTH_TOKEN] = token;
|
||||||
}
|
}
|
||||||
const params = { headers };
|
const params = { headers };
|
||||||
|
@ -22,7 +22,7 @@ const getParams = (user) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useDegradedPerformance(onDegradedPerformanceCallback, user) {
|
export function useDegradedPerformance(onDegradedPerformanceCallback, user) {
|
||||||
const hasUser = user !== undefined;
|
const hasUser = user !== undefined && user !== null;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasUser) {
|
if (hasUser) {
|
||||||
|
|
Loading…
Reference in a new issue