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

59 lines
2.5 KiB
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import { connect } from "react-redux";
import { selectPlatform, selectCurrentModal } from "selectors/app";
import {
makeSelectFileInfoForUri,
makeSelectDownloadingForUri,
makeSelectLoadingForUri,
2017-06-06 23:19:12 +02:00
} from "selectors/file_info";
import { makeSelectIsAvailableForUri } from "selectors/availability";
import { makeSelectCostInfoForUri } from "selectors/cost_info";
2017-08-26 04:09:56 +02:00
import { doCloseModal, doOpenModal, doNavigate } from "actions/app";
2017-06-06 23:19:12 +02:00
import { doFetchAvailability } from "actions/availability";
2017-07-02 20:23:38 +02:00
import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info";
import {
makeSelectClaimForUriIsMine,
makeSelectClaimForUri,
} from "selectors/claims";
import { doPurchaseUri, doLoadVideo, doStartDownload } from "actions/content";
2017-06-06 23:19:12 +02:00
import FileActions from "./view";
const makeSelect = () => {
2017-06-06 23:19:12 +02:00
const selectFileInfoForUri = makeSelectFileInfoForUri();
const selectIsAvailableForUri = makeSelectIsAvailableForUri();
const selectDownloadingForUri = makeSelectDownloadingForUri();
const selectCostInfoForUri = makeSelectCostInfoForUri();
const selectLoadingForUri = makeSelectLoadingForUri();
const selectClaimForUriIsMine = makeSelectClaimForUriIsMine();
const selectClaimForUri = makeSelectClaimForUri();
const select = (state, props) => ({
fileInfo: selectFileInfoForUri(state, props),
2017-06-16 02:02:46 +02:00
/*availability check is disabled due to poor performance, TBD if it dies forever or requires daemon fix*/
isAvailable: true, //selectIsAvailableForUri(state, props),
platform: selectPlatform(state),
modal: selectCurrentModal(state),
downloading: selectDownloadingForUri(state, props),
costInfo: selectCostInfoForUri(state, props),
loading: selectLoadingForUri(state, props),
claimIsMine: selectClaimForUriIsMine(state, props),
claimInfo: selectClaimForUri(state, props),
2017-06-06 23:19:12 +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-06-06 23:19:12 +02:00
checkAvailability: uri => dispatch(doFetchAvailability(uri)),
closeModal: () => dispatch(doCloseModal()),
2017-06-06 23:19:12 +02:00
openInFolder: fileInfo => dispatch(doOpenFileInFolder(fileInfo)),
openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)),
openModal: modal => dispatch(doOpenModal(modal)),
startDownload: uri => dispatch(doPurchaseUri(uri, "affirmPurchase")),
loadVideo: uri => dispatch(doLoadVideo(uri)),
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
2017-08-26 04:09:56 +02:00
navigate: (path, params) => dispatch(doNavigate(path, params)),
2017-06-06 06:21:55 +02:00
});
2017-06-06 06:21:55 +02:00
export default connect(makeSelect, perform)(FileActions);