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

30 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import { connect } from "react-redux";
2017-09-08 05:15:05 +02:00
import { makeSelectFileInfoForUri } from "selectors/file_info";
2017-06-06 23:19:12 +02:00
import { makeSelectCostInfoForUri } from "selectors/cost_info";
2017-09-07 23:18:33 +02:00
import { doOpenModal } from "actions/app";
2017-06-06 23:19:12 +02:00
import { doFetchAvailability } from "actions/availability";
2017-09-17 20:26:55 +02:00
import { doOpenFileInShell } from "actions/file_info";
2017-09-08 05:15:05 +02:00
import { makeSelectClaimIsMine } from "selectors/claims";
2017-09-17 20:26:55 +02:00
import { doPurchaseUri, doStartDownload } from "actions/content";
2017-09-07 15:38:44 +02:00
import { doNavigate } from "actions/navigation";
2017-06-06 23:19:12 +02:00
import FileActions from "./view";
2017-09-08 05:15:05 +02:00
const select = (state, props) => ({
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
/*availability check is disabled due to poor performance, TBD if it dies forever or requires daemon fix*/
costInfo: makeSelectCostInfoForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
});
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
2017-06-06 23:19:12 +02:00
checkAvailability: uri => dispatch(doFetchAvailability(uri)),
2017-09-17 20:26:55 +02:00
navigate: (path, params) => dispatch(doNavigate(path, params)),
2017-06-06 23:19:12 +02:00
openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)),
2017-09-08 05:15:05 +02:00
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
startDownload: uri => dispatch(doPurchaseUri(uri)),
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
2017-06-06 06:21:55 +02:00
});
2017-09-08 05:15:05 +02:00
export default connect(select, perform)(FileActions);