mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 09:45:10 +00:00
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 { makeSelectThumbnailForUri, doResolveUri, makeSelectClaimForUri } from 'lbry-redux';
|
||||||
import { doFetchCostInfoForUri } from 'lbryinc';
|
import { doFetchCostInfoForUri } from 'lbryinc';
|
||||||
import { doSetFloatingUri, doPlayUri } from 'redux/actions/content';
|
import { doSetFloatingUri, doPlayUri } from 'redux/actions/content';
|
||||||
|
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import ChannelThumbnail from './view';
|
import ChannelThumbnail from './view';
|
||||||
|
|
||||||
|
@ -17,4 +18,5 @@ export default connect(select, {
|
||||||
doFetchCostInfoForUri,
|
doFetchCostInfoForUri,
|
||||||
doSetFloatingUri,
|
doSetFloatingUri,
|
||||||
doPlayUri,
|
doPlayUri,
|
||||||
|
doAnaltyicsPurchaseEvent,
|
||||||
})(ChannelThumbnail);
|
})(ChannelThumbnail);
|
||||||
|
|
|
@ -14,7 +14,8 @@ type Props = {
|
||||||
doFetchCostInfoForUri: string => void,
|
doFetchCostInfoForUri: string => void,
|
||||||
doSetFloatingUri: string => void,
|
doSetFloatingUri: string => void,
|
||||||
floatingPlayerEnabled: boolean,
|
floatingPlayerEnabled: boolean,
|
||||||
doPlayUri: string => void,
|
doPlayUri: (string, ?boolean, ?boolean, (GetResponse) => void) => void,
|
||||||
|
doAnaltyicsPurchaseEvent: GetResponse => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function FileRenderFloating(props: Props) {
|
export default function FileRenderFloating(props: Props) {
|
||||||
|
@ -27,30 +28,36 @@ export default function FileRenderFloating(props: Props) {
|
||||||
doSetFloatingUri,
|
doSetFloatingUri,
|
||||||
floatingPlayerEnabled,
|
floatingPlayerEnabled,
|
||||||
doPlayUri,
|
doPlayUri,
|
||||||
|
doAnaltyicsPurchaseEvent,
|
||||||
} = props;
|
} = props;
|
||||||
const { push } = useHistory();
|
const { push } = useHistory();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const hasResolvedUri = claim !== undefined;
|
const hasResolvedUri = claim !== undefined;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasResolvedUri) {
|
doResolveUri(uri);
|
||||||
doResolveUri(uri);
|
doFetchCostInfoForUri(uri);
|
||||||
doFetchCostInfoForUri(uri);
|
}, [uri, doResolveUri, doFetchCostInfoForUri]);
|
||||||
}
|
|
||||||
}, [uri, hasResolvedUri, doResolveUri, doFetchCostInfoForUri]);
|
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
|
if (!hasResolvedUri) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isMobile || !floatingPlayerEnabled) {
|
if (isMobile || !floatingPlayerEnabled) {
|
||||||
const formattedUrl = formatLbryUrlForWeb(uri);
|
const formattedUrl = formatLbryUrlForWeb(uri);
|
||||||
push(formattedUrl);
|
push(formattedUrl);
|
||||||
} else {
|
} else {
|
||||||
doSetFloatingUri(uri);
|
doPlayUri(uri, undefined, undefined, fileInfo => {
|
||||||
doPlayUri(uri);
|
doSetFloatingUri(uri);
|
||||||
|
doAnaltyicsPurchaseEvent(fileInfo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
disabled={!hasResolvedUri}
|
||||||
role="button"
|
role="button"
|
||||||
className="embed__inline-button"
|
className="embed__inline-button"
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
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 { doHideModal, doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
||||||
import { makeSelectMetadataForUri } from 'lbry-redux';
|
import { makeSelectMetadataForUri } from 'lbry-redux';
|
||||||
import ModalAffirmPurchase from './view';
|
import ModalAffirmPurchase from './view';
|
||||||
|
@ -11,7 +11,8 @@ const select = (state, props) => ({
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
analyticsPurchaseEvent: fileInfo => dispatch(doAnaltyicsPurchaseEvent(fileInfo)),
|
analyticsPurchaseEvent: fileInfo => dispatch(doAnaltyicsPurchaseEvent(fileInfo)),
|
||||||
cancelPurchase: () => {
|
cancelPurchase: () => {
|
||||||
dispatch(doSetPlayingUri(null));
|
// TODO: Find a way to add this back without messing up embeds
|
||||||
|
// dispatch(doSetPlayingUri(null));
|
||||||
dispatch(doHideModal());
|
dispatch(doHideModal());
|
||||||
},
|
},
|
||||||
closeModal: () => dispatch(doHideModal()),
|
closeModal: () => dispatch(doHideModal()),
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry-redux';
|
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
|
@ -90,12 +89,12 @@ reducers[ACTIONS.CLEAR_CONTENT_HISTORY_URI] = (state, action) => {
|
||||||
|
|
||||||
reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = state => ({ ...state, history: [] });
|
reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = state => ({ ...state, history: [] });
|
||||||
|
|
||||||
reducers[LBRY_REDUX_ACTIONS.PURCHASE_URI_FAILED] = (state, action) => {
|
// reducers[LBRY_REDUX_ACTIONS.PURCHASE_URI_FAILED] = (state, action) => {
|
||||||
return {
|
// return {
|
||||||
...state,
|
// ...state,
|
||||||
playingUri: null,
|
// playingUri: null,
|
||||||
};
|
// };
|
||||||
};
|
// };
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export default function reducer(state = defaultState, action) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
|
|
Loading…
Add table
Reference in a new issue