lbry-desktop/ui/js/component/video/index.js

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import { connect } from "react-redux";
import { doCloseModal } from "actions/app";
import { doNavigate } from "actions/app";
2017-06-06 23:19:12 +02:00
import { selectCurrentModal } from "selectors/app";
import { doPurchaseUri, doLoadVideo } from "actions/content";
2017-04-23 11:56:50 +02:00
import {
makeSelectMetadataForUri,
makeSelectContentTypeForUri,
2017-06-06 23:19:12 +02:00
} from "selectors/claims";
2017-05-15 05:50:59 +02:00
import {
makeSelectFileInfoForUri,
makeSelectLoadingForUri,
makeSelectDownloadingForUri,
2017-06-06 23:19:12 +02:00
} from "selectors/file_info";
import { makeSelectCostInfoForUri } from "selectors/cost_info";
import { selectObscureNsfw } from "selectors/app";
2017-06-06 23:19:12 +02:00
import Video from "./view";
2017-05-15 05:50:59 +02:00
const makeSelect = () => {
2017-06-06 23:19:12 +02:00
const selectCostInfo = makeSelectCostInfoForUri();
const selectFileInfo = makeSelectFileInfoForUri();
const selectIsLoading = makeSelectLoadingForUri();
const selectIsDownloading = makeSelectDownloadingForUri();
const selectMetadata = makeSelectMetadataForUri();
const selectContentType = makeSelectContentTypeForUri();
2017-05-15 05:50:59 +02:00
const select = (state, props) => ({
costInfo: selectCostInfo(state, props),
fileInfo: selectFileInfo(state, props),
metadata: selectMetadata(state, props),
obscureNsfw: selectObscureNsfw(state),
2017-05-15 05:50:59 +02:00
modal: selectCurrentModal(state),
isLoading: selectIsLoading(state, props),
isDownloading: selectIsDownloading(state, props),
contentType: selectContentType(state, props),
2017-06-06 23:19:12 +02:00
});
2017-05-15 05:50:59 +02:00
2017-06-06 23:19:12 +02:00
return select;
2017-06-06 06:21:55 +02:00
};
2017-04-23 11:56:50 +02:00
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
2017-06-06 23:19:12 +02:00
loadVideo: uri => dispatch(doLoadVideo(uri)),
purchaseUri: uri => dispatch(doPurchaseUri(uri, "affirmPurchaseAndPlay")),
2017-04-23 11:56:50 +02:00
closeModal: () => dispatch(doCloseModal()),
2017-06-06 06:21:55 +02:00
});
2017-04-23 11:56:50 +02:00
2017-06-06 06:21:55 +02:00
export default connect(makeSelect, perform)(Video);