lbry-desktop/ui/js/page/file/index.js

46 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import { connect } from "react-redux";
import { doNavigate } from "actions/navigation";
2017-09-02 05:59:25 +02:00
import { doFetchFileInfo, doFetchPublishedDate } from "actions/file_info";
import { makeSelectFileInfoForUri, selectPublishedDate } from "selectors/file_info";
2017-07-30 00:56:08 +02:00
import { selectRewardContentClaimIds } from "selectors/content";
2017-06-06 23:19:12 +02:00
import { doFetchCostInfoForUri } from "actions/cost_info";
2017-04-28 17:14:44 +02:00
import {
2017-05-15 05:50:59 +02:00
makeSelectClaimForUri,
makeSelectContentTypeForUri,
makeSelectMetadataForUri,
2017-06-06 23:19:12 +02:00
} from "selectors/claims";
import { makeSelectCostInfoForUri } from "selectors/cost_info";
2017-06-28 09:12:01 +02:00
import { selectShowNsfw } from "selectors/settings";
2017-06-06 23:19:12 +02:00
import FilePage from "./view";
2017-05-15 05:50:59 +02:00
const makeSelect = () => {
const selectClaim = makeSelectClaimForUri(),
2017-06-06 23:19:12 +02:00
selectContentType = makeSelectContentTypeForUri(),
selectFileInfo = makeSelectFileInfoForUri(),
selectCostInfo = makeSelectCostInfoForUri(),
selectMetadata = makeSelectMetadataForUri();
2017-05-15 05:50:59 +02:00
const select = (state, props) => ({
claim: selectClaim(state, props),
contentType: selectContentType(state, props),
costInfo: selectCostInfo(state, props),
metadata: selectMetadata(state, props),
obscureNsfw: !selectShowNsfw(state),
2017-06-06 23:19:12 +02:00
fileInfo: selectFileInfo(state, props),
2017-07-30 00:56:08 +02:00
rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
2017-09-02 05:59:25 +02:00
publishedDate: selectPublishedDate(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-06-06 06:21:55 +02:00
const perform = dispatch => ({
2017-05-21 16:42:34 +02:00
navigate: (path, params) => dispatch(doNavigate(path, params)),
2017-06-06 23:19:12 +02:00
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
2017-09-02 05:59:25 +02:00
fetchPublishedDate: height => dispatch(doFetchPublishedDate(height)),
2017-06-06 06:21:55 +02:00
});
2017-06-06 06:21:55 +02:00
export default connect(makeSelect, perform)(FilePage);