lbry-desktop/ui/js/component/fileCard/index.js
2017-06-06 17:19:12 -04:00

37 lines
1.3 KiB
JavaScript

import React from "react";
import { connect } from "react-redux";
import { doNavigate } from "actions/app";
import { doResolveUri, doCancelResolveUri } from "actions/content";
import { selectObscureNsfw } from "selectors/app";
import {
makeSelectClaimForUri,
makeSelectMetadataForUri,
} from "selectors/claims";
import { makeSelectFileInfoForUri } from "selectors/file_info";
import { makeSelectIsResolvingForUri } from "selectors/content";
import FileCard from "./view";
const makeSelect = () => {
const selectClaimForUri = makeSelectClaimForUri();
const selectFileInfoForUri = makeSelectFileInfoForUri();
const selectMetadataForUri = makeSelectMetadataForUri();
const selectResolvingUri = makeSelectIsResolvingForUri();
const select = (state, props) => ({
claim: selectClaimForUri(state, props),
fileInfo: selectFileInfoForUri(state, props),
obscureNsfw: selectObscureNsfw(state),
metadata: selectMetadataForUri(state, props),
isResolvingUri: selectResolvingUri(state, props),
});
return select;
};
const perform = dispatch => ({
navigate: (path, params) => dispatch(doNavigate(path, params)),
resolveUri: uri => dispatch(doResolveUri(uri)),
cancelResolveUri: uri => dispatch(doCancelResolveUri(uri)),
});
export default connect(makeSelect, perform)(FileCard);