diff --git a/ui/component/app/view.jsx b/ui/component/app/view.jsx
index 9b2c64304..a8d54e4c1 100644
--- a/ui/component/app/view.jsx
+++ b/ui/component/app/view.jsx
@@ -30,6 +30,7 @@ import OpenInAppLink from 'web/component/openInAppLink';
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
import NagDegradedPerformance from 'web/component/nag-degraded-performance';
import NagDataCollection from 'web/component/nag-data-collection';
+import NagNoUser from 'web/component/nag-no-user';
import {
useDegradedPerformance,
STATUS_OK,
@@ -363,7 +364,7 @@ function App(props: Props) {
// 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
- if (!user) {
+ if (user === undefined) {
return (
@@ -428,6 +429,7 @@ function App(props: Props) {
{!SIMPLE_SITE && lbryTvApiStatus === STATUS_OK && showAnalyticsNag && !shouldHideNag && (
)}
+ {user === null && }
{/* @endif */}
)}
diff --git a/ui/component/button/index.js b/ui/component/button/index.js
index a2c913df7..f50b0e001 100644
--- a/ui/component/button/index.js
+++ b/ui/component/button/index.js
@@ -1,11 +1,12 @@
import Button from './view';
import React, { forwardRef } from 'react';
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,
emailVerified: selectUserVerifiedEmail(state),
+ user: selectUser(state),
});
const ConnectedButton = connect(mapStateToProps)(Button);
diff --git a/ui/component/button/view.jsx b/ui/component/button/view.jsx
index 119e83fdf..1775ab4b8 100644
--- a/ui/component/button/view.jsx
+++ b/ui/component/button/view.jsx
@@ -38,6 +38,7 @@ type Props = {
myref: any,
dispatch: any,
'aria-label'?: string,
+ user: ?User,
};
// use forwardRef to allow consumers to pass refs to the button content if they want to
@@ -69,10 +70,14 @@ const Button = forwardRef((props: Props, ref: any) => {
myref,
dispatch, //
);
diff --git a/ui/redux/actions/app.js b/ui/redux/actions/app.js
index 3178d6e94..0eedeb593 100644
--- a/ui/redux/actions/app.js
+++ b/ui/redux/actions/app.js
@@ -503,17 +503,18 @@ export function doAnalyticsBuffer(uri, bufferData) {
const fileSize = source.size; // size in bytes
const fileSizeInBits = fileSize * 8;
const bitRate = parseInt(fileSizeInBits / fileDurationInSeconds);
- const userId = user.id.toString();
-
- analytics.videoBufferEvent(claim, {
- timeAtBuffer,
- bufferDuration,
- bitRate,
- userId,
- duration: fileDurationInSeconds,
- playerPoweredBy: bufferData.playerPoweredBy,
- readyState: bufferData.readyState,
- });
+ const userId = user && user.id.toString();
+ if (userId) {
+ analytics.videoBufferEvent(claim, {
+ timeAtBuffer,
+ bufferDuration,
+ bitRate,
+ userId,
+ duration: fileDurationInSeconds,
+ playerPoweredBy: bufferData.playerPoweredBy,
+ readyState: bufferData.readyState,
+ });
+ }
};
}
diff --git a/ui/redux/actions/user.js b/ui/redux/actions/user.js
index 5738eb3c0..22d34f68a 100644
--- a/ui/redux/actions/user.js
+++ b/ui/redux/actions/user.js
@@ -101,7 +101,7 @@ export function doInstallNewWithParams(
function checkAuthBusy() {
let time = Date.now();
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
(function waitForAuth() {
try {
sessionStorage.setItem('test', 'available');
diff --git a/web/component/nag-no-user.jsx b/web/component/nag-no-user.jsx
new file mode 100644
index 000000000..dc0a6509e
--- /dev/null
+++ b/web/component/nag-no-user.jsx
@@ -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 (
+
+ %DOMAIN% id not available. Account functions will be unavailable. Refresh to try again.
+
+ }
+ actionText={__('Refresh')}
+ onClick={() => window.location.reload()}
+ />
+ );
+}
diff --git a/web/effects/use-degraded-performance.js b/web/effects/use-degraded-performance.js
index bf00f0487..5c1e26c36 100644
--- a/web/effects/use-degraded-performance.js
+++ b/web/effects/use-degraded-performance.js
@@ -14,7 +14,7 @@ export const STATUS_DOWN = 'down';
const getParams = (user) => {
const headers = {};
const token = getAuthToken();
- if (token && user.has_verified_email) {
+ if (token && user && user.has_verified_email) {
headers[X_LBRY_AUTH_TOKEN] = token;
}
const params = { headers };
@@ -22,7 +22,7 @@ const getParams = (user) => {
};
export function useDegradedPerformance(onDegradedPerformanceCallback, user) {
- const hasUser = user !== undefined;
+ const hasUser = user !== undefined && user !== null;
useEffect(() => {
if (hasUser) {