Merge pull request #2420 from lbryio/routing-fixes

Web fixes
This commit is contained in:
Sean Yesmunt 2019-04-11 15:31:46 -04:00 committed by GitHub
commit 6fe6696768
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 78 additions and 42 deletions

View file

@ -74,6 +74,7 @@
"classnames": "^2.2.5", "classnames": "^2.2.5",
"codemirror": "^5.39.2", "codemirror": "^5.39.2",
"connected-react-router": "^6.3.2", "connected-react-router": "^6.3.2",
"cookie": "^0.3.1",
"copy-webpack-plugin": "^4.6.0", "copy-webpack-plugin": "^4.6.0",
"country-data": "^0.0.31", "country-data": "^0.0.31",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",

View file

@ -72,11 +72,12 @@ const analytics: Analytics = {
// Initialize google analytics // Initialize google analytics
// Set `debug: true` for debug info // Set `debug: true` for debug info
// Currently doesn't actually differentiate between web/desktop // Will change once we have separate ids for desktop/web
ReactGA.initialize('UA-60403362-12', { const UA_ID = IS_WEB ? 'UA-60403362-12' : 'UA-60403362-12';
ReactGA.initialize(UA_ID, {
gaOptions: { name: IS_WEB ? 'web' : 'desktop' }, gaOptions: { name: IS_WEB ? 'web' : 'desktop' },
testMode: process.env.NODE_ENV !== 'production', testMode: process.env.NODE_ENV !== 'production',
// debug: true,
}); });
// Manually call the first page view // Manually call the first page view

View file

@ -121,7 +121,11 @@ export default class FirstRun extends PureComponent<Props> {
<div className="card__content"> <div className="card__content">
<p>{__("Check out some of the neat content below me. I'll see you around!")}</p> <p>{__("Check out some of the neat content below me. I'll see you around!")}</p>
<div className="card__actions"> <div className="card__actions">
<Button button="primary" onClick={completeFirstRun} label={__('See You Later')} /> <Button
button="primary"
onClick={completeFirstRun}
label={__('Lets Get Started')}
/>
</div> </div>
</div> </div>
</Help> </Help>

View file

@ -2,11 +2,9 @@
import type { Claim } from 'types/claim'; import type { Claim } from 'types/claim';
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import { stopContextMenu } from 'util/context-menu'; import { stopContextMenu } from 'util/context-menu';
import( import(/* webpackChunkName: "videojs" */
/* webpackChunkName: "videojs" */ /* webpackPreload: true */
/* webpackPreload: true */ 'video.js/dist/video-js.css');
'video.js/dist/video-js.css'
);
type Props = { type Props = {
source: { source: {
@ -25,7 +23,9 @@ class AudioVideoViewer extends React.PureComponent<Props> {
componentDidMount() { componentDidMount() {
const { contentType, poster, claim } = this.props; const { contentType, poster, claim } = this.props;
const path = `https://api.lbry.tv/content/claims/${claim.name}/${claim.claim_id}/stream.mp4`; const path = `https://api.piratebay.com/content/claims/${claim.name}/${
claim.claim_id
}/stream.mp4`;
const sources = [ const sources = [
{ {
src: path, src: path,
@ -41,12 +41,10 @@ class AudioVideoViewer extends React.PureComponent<Props> {
sources, sources,
}; };
import( import(/* webpackChunkName: "videojs" */
/* webpackChunkName: "videojs" */ /* webpackMode: "lazy" */
/* webpackMode: "lazy" */ /* webpackPreload: true */
/* webpackPreload: true */ 'video.js').then(videojs => {
'video.js'
).then(videojs => {
if (videojs.__esModule) { if (videojs.__esModule) {
videojs = videojs.default; videojs = videojs.default;
} }

View file

@ -21,17 +21,16 @@ import {
import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux'; import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux';
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings'; import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
import { doAuthenticate, Lbryio, rewards, doBlackListedOutpointsSubscribe } from 'lbryinc'; import { doAuthenticate, Lbryio, rewards, doBlackListedOutpointsSubscribe } from 'lbryinc';
import(
/* webpackChunkName: "styles" */
/* webpackPrefetch: true */
'scss/all.scss'
);
import { store, history } from 'store'; import { store, history } from 'store';
import pjson from 'package.json'; import pjson from 'package.json';
import app from './app'; import app from './app';
import analytics from './analytics'; import analytics from './analytics';
import doLogWarningConsoleMessage from './logWarningConsoleMessage'; import doLogWarningConsoleMessage from './logWarningConsoleMessage';
import { ConnectedRouter } from 'connected-react-router'; import { ConnectedRouter } from 'connected-react-router';
import cookie from 'cookie';
import(/* webpackChunkName: "styles" */
/* webpackPrefetch: true */
'scss/all.scss');
const APPPAGEURL = 'lbry://?'; const APPPAGEURL = 'lbry://?';
@ -67,7 +66,7 @@ Lbry.setDaemonConnectionString(SDK_API_URL);
// We interect with ipcRenderer to get the auth key from a users keyring // We interect with ipcRenderer to get the auth key from a users keyring
// We keep a local variable for authToken beacuse `ipcRenderer.send` does not // We keep a local variable for authToken beacuse `ipcRenderer.send` does not
// contain a response, so there is no way to know when it's been set // contain a response, so there is no way to know when it's been set
// @if TARGET='app'
let authToken; let authToken;
Lbryio.setOverride( Lbryio.setOverride(
'setAuthToken', 'setAuthToken',
@ -89,6 +88,9 @@ Lbryio.setOverride(
const newAuthToken = response.auth_token; const newAuthToken = response.auth_token;
authToken = newAuthToken; authToken = newAuthToken;
// @if TARGET='web'
document.cookie = cookie.serialize('auth_token', authToken);
// @endif
// @if TARGET='app' // @if TARGET='app'
ipcRenderer.send('set-auth-token', authToken); ipcRenderer.send('set-auth-token', authToken);
// @endif // @endif
@ -112,10 +114,13 @@ Lbryio.setOverride(
ipcRenderer.send('get-auth-token'); ipcRenderer.send('get-auth-token');
// @endif // @endif
// @if TARGET='web'
const { auth_token: authToken } = cookie.parse(document.cookie);
resolve(authToken);
// @endif
} }
}) })
); );
// @endif
rewards.setCallback('claimFirstRewardSuccess', () => { rewards.setCallback('claimFirstRewardSuccess', () => {
app.store.dispatch(doOpenModal(MODALS.FIRST_REWARD)); app.store.dispatch(doOpenModal(MODALS.FIRST_REWARD));

View file

@ -2,10 +2,12 @@ import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideModal } from 'redux/actions/app';
import ModalSendTip from './view'; import ModalSendTip from './view';
import { doClearPublish } from 'redux/actions/publish'; import { doClearPublish } from 'redux/actions/publish';
import { push } from 'connected-react-router';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideModal()),
clearPublish: () => dispatch(doClearPublish()), clearPublish: () => dispatch(doClearPublish()),
navigate: path => dispatch(push(path)),
}); });
export default connect( export default connect(

View file

@ -9,7 +9,7 @@ type Props = {
uri: string, uri: string,
}; };
class ModalSendTip extends React.PureComponent<Props> { class ModalPublishSuccess extends React.PureComponent<Props> {
render() { render() {
const { closeModal, clearPublish, navigate, uri } = this.props; const { closeModal, clearPublish, navigate, uri } = this.props;
@ -20,7 +20,7 @@ class ModalSendTip extends React.PureComponent<Props> {
contentLabel={__('File published')} contentLabel={__('File published')}
onConfirmed={() => { onConfirmed={() => {
clearPublish(); clearPublish();
navigate('/published'); navigate('/$/published');
closeModal(); closeModal();
}} }}
> >
@ -38,4 +38,4 @@ class ModalSendTip extends React.PureComponent<Props> {
} }
} }
export default ModalSendTip; export default ModalPublishSuccess;

View file

@ -1,16 +1,24 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideModal } from 'redux/actions/app';
import { withRouter } from 'react-router-dom';
import ModalRewardApprovalRequired from './view'; import ModalRewardApprovalRequired from './view';
const perform = dispatch => ({ const perform = (dispatch, ownProps) => ({
doAuth: () => { doAuth: () => {
const {
location: { pathname },
history,
} = ownProps;
const currentPath = pathname.split('/$/')[1];
dispatch(doHideModal()); dispatch(doHideModal());
// dispatch(doAuthNavigate()); history.push(`/$/auth?redirect=${currentPath}`);
}, },
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideModal()),
}); });
export default connect( export default withRouter(
null, connect(
perform null,
)(ModalRewardApprovalRequired); perform
)(ModalRewardApprovalRequired)
);

View file

@ -9,8 +9,8 @@ const select = state => ({
deamonSettings: selectDaemonSettings(state), deamonSettings: selectDaemonSettings(state),
}); });
const perform = dispatch => ({ const perform = (dispatch, ownProps) => ({
// doAuth: () => dispatch(doAuthNavigate('/help')), doAuth: () => ownProps.history.push('/$/auth?redirect=help'),
fetchAccessToken: () => dispatch(doFetchAccessToken()), fetchAccessToken: () => dispatch(doFetchAccessToken()),
}); });

View file

@ -23,6 +23,7 @@ import {
} from 'redux/selectors/app'; } from 'redux/selectors/app';
import { doAuthenticate } from 'lbryinc'; import { doAuthenticate } from 'lbryinc';
import { lbrySettings as config, version as appVersion } from 'package.json'; import { lbrySettings as config, version as appVersion } from 'package.json';
import { push } from 'connected-react-router';
// @if TARGET='app' // @if TARGET='app'
const { autoUpdater } = remote.require('electron-updater'); const { autoUpdater } = remote.require('electron-updater');
@ -388,7 +389,7 @@ export function doConditionalAuthNavigate(newSession) {
const modal = selectModal(state); const modal = selectModal(state);
if (newSession || (modal && modal.id !== MODALS.EMAIL_COLLECTION)) { if (newSession || (modal && modal.id !== MODALS.EMAIL_COLLECTION)) {
// dispatch(doAuthNavigate()); dispatch(push('/$/auth'));
} }
}; };
} }

View file

@ -74,21 +74,37 @@ const walletFilter = createFilter('wallet', ['receiveAddress']);
const searchFilter = createFilter('search', ['options']); const searchFilter = createFilter('search', ['options']);
const persistOptions = { const persistOptions = {
whitelist: ['subscriptions', 'publish', 'wallet', 'content', 'fileInfo', 'app', 'search'], whitelist: [
// @if TARGET='app'
'publish',
'wallet',
'fileInfo',
// @endif
'content',
'subscriptions',
'app',
'search',
],
// Order is important. Needs to be compressed last or other transforms can't // Order is important. Needs to be compressed last or other transforms can't
// read the data // read the data
transforms: [walletFilter, contentFilter, fileInfoFilter, appFilter, searchFilter, compressor], transforms: [
debounce: 10000, // @if TARGET='app'
walletFilter,
contentFilter,
fileInfoFilter,
// @endif
appFilter,
searchFilter,
compressor,
],
debounce: IS_WEB ? 5000 : 10000,
storage: localForage, storage: localForage,
}; };
// Dont' persist anything on web (for now)
// @if TARGET='app'
window.cacheStore = persistStore(store, persistOptions, err => { window.cacheStore = persistStore(store, persistOptions, err => {
if (err) { if (err) {
console.error('Unable to load saved settings'); console.error('Unable to load saved settings');
} }
}); });
// @endif
export { store, history }; export { store, history };

View file

@ -2696,7 +2696,7 @@ cookie-signature@1.0.6:
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"
integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw=
cookie@0.3.1: cookie@0.3.1, cookie@^0.3.1:
version "0.3.1" version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=