fix embed player
This commit is contained in:
parent
e4500d692f
commit
4c768b3814
4 changed files with 26 additions and 17 deletions
|
@ -3,6 +3,7 @@ import { connect } from 'react-redux';
|
|||
import { makeSelectThumbnailForUri, doResolveUri, makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { doFetchCostInfoForUri } from 'lbryinc';
|
||||
import { doSetFloatingUri, doPlayUri } from 'redux/actions/content';
|
||||
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import ChannelThumbnail from './view';
|
||||
|
||||
|
@ -17,4 +18,5 @@ export default connect(select, {
|
|||
doFetchCostInfoForUri,
|
||||
doSetFloatingUri,
|
||||
doPlayUri,
|
||||
doAnaltyicsPurchaseEvent,
|
||||
})(ChannelThumbnail);
|
||||
|
|
|
@ -14,7 +14,8 @@ type Props = {
|
|||
doFetchCostInfoForUri: string => void,
|
||||
doSetFloatingUri: string => void,
|
||||
floatingPlayerEnabled: boolean,
|
||||
doPlayUri: string => void,
|
||||
doPlayUri: (string, ?boolean, ?boolean, (GetResponse) => void) => void,
|
||||
doAnaltyicsPurchaseEvent: GetResponse => void,
|
||||
};
|
||||
|
||||
export default function FileRenderFloating(props: Props) {
|
||||
|
@ -27,30 +28,36 @@ export default function FileRenderFloating(props: Props) {
|
|||
doSetFloatingUri,
|
||||
floatingPlayerEnabled,
|
||||
doPlayUri,
|
||||
doAnaltyicsPurchaseEvent,
|
||||
} = props;
|
||||
const { push } = useHistory();
|
||||
const isMobile = useIsMobile();
|
||||
const hasResolvedUri = claim !== undefined;
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasResolvedUri) {
|
||||
doResolveUri(uri);
|
||||
doFetchCostInfoForUri(uri);
|
||||
}
|
||||
}, [uri, hasResolvedUri, doResolveUri, doFetchCostInfoForUri]);
|
||||
}, [uri, doResolveUri, doFetchCostInfoForUri]);
|
||||
|
||||
function handleClick() {
|
||||
if (!hasResolvedUri) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMobile || !floatingPlayerEnabled) {
|
||||
const formattedUrl = formatLbryUrlForWeb(uri);
|
||||
push(formattedUrl);
|
||||
} else {
|
||||
doPlayUri(uri, undefined, undefined, fileInfo => {
|
||||
doSetFloatingUri(uri);
|
||||
doPlayUri(uri);
|
||||
doAnaltyicsPurchaseEvent(fileInfo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
disabled={!hasResolvedUri}
|
||||
role="button"
|
||||
className="embed__inline-button"
|
||||
onClick={handleClick}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
|
||||
import { doPlayUri } from 'redux/actions/content';
|
||||
import { doHideModal, doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
||||
import { makeSelectMetadataForUri } from 'lbry-redux';
|
||||
import ModalAffirmPurchase from './view';
|
||||
|
@ -11,7 +11,8 @@ const select = (state, props) => ({
|
|||
const perform = dispatch => ({
|
||||
analyticsPurchaseEvent: fileInfo => dispatch(doAnaltyicsPurchaseEvent(fileInfo)),
|
||||
cancelPurchase: () => {
|
||||
dispatch(doSetPlayingUri(null));
|
||||
// TODO: Find a way to add this back without messing up embeds
|
||||
// dispatch(doSetPlayingUri(null));
|
||||
dispatch(doHideModal());
|
||||
},
|
||||
closeModal: () => dispatch(doHideModal()),
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as ACTIONS from 'constants/action_types';
|
||||
import { ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry-redux';
|
||||
|
||||
const reducers = {};
|
||||
const defaultState = {
|
||||
|
@ -90,12 +89,12 @@ reducers[ACTIONS.CLEAR_CONTENT_HISTORY_URI] = (state, action) => {
|
|||
|
||||
reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = state => ({ ...state, history: [] });
|
||||
|
||||
reducers[LBRY_REDUX_ACTIONS.PURCHASE_URI_FAILED] = (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
playingUri: null,
|
||||
};
|
||||
};
|
||||
// reducers[LBRY_REDUX_ACTIONS.PURCHASE_URI_FAILED] = (state, action) => {
|
||||
// return {
|
||||
// ...state,
|
||||
// playingUri: null,
|
||||
// };
|
||||
// };
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
const handler = reducers[action.type];
|
||||
|
|
Loading…
Reference in a new issue