2017-06-06 23:19:12 +02:00
|
|
|
import React from "react";
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
import { selectPlatform } from "selectors/app";
|
2017-04-29 19:02:25 +02:00
|
|
|
import {
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectDownloadingForUri,
|
|
|
|
makeSelectLoadingForUri,
|
2017-06-06 23:19:12 +02:00
|
|
|
} from "selectors/file_info";
|
|
|
|
import { makeSelectIsAvailableForUri } from "selectors/availability";
|
|
|
|
import { selectCurrentModal } from "selectors/app";
|
|
|
|
import { makeSelectCostInfoForUri } from "selectors/cost_info";
|
|
|
|
import { doCloseModal, doOpenModal, doHistoryBack } from "actions/app";
|
|
|
|
import { doFetchAvailability } from "actions/availability";
|
2017-04-29 19:02:25 +02:00
|
|
|
import {
|
|
|
|
doOpenFileInShell,
|
|
|
|
doOpenFileInFolder,
|
|
|
|
doDeleteFile,
|
2017-06-06 23:19:12 +02:00
|
|
|
} from "actions/file_info";
|
2017-06-29 09:44:34 +02:00
|
|
|
import { makeSelectClaimForUriIsMine } from "selectors/claims";
|
2017-06-06 23:19:12 +02:00
|
|
|
import { doPurchaseUri, doLoadVideo } from "actions/content";
|
|
|
|
import FileActions from "./view";
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2017-04-29 19:02:25 +02:00
|
|
|
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();
|
2017-06-29 09:44:34 +02:00
|
|
|
const selectClaimForUriIsMine = makeSelectClaimForUriIsMine();
|
2017-04-29 19:02:25 +02:00
|
|
|
|
|
|
|
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),
|
2017-04-29 19:02:25 +02:00
|
|
|
platform: selectPlatform(state),
|
|
|
|
modal: selectCurrentModal(state),
|
|
|
|
downloading: selectDownloadingForUri(state, props),
|
2017-05-28 16:24:10 +02:00
|
|
|
costInfo: selectCostInfoForUri(state, props),
|
2017-06-02 09:40:40 +02:00
|
|
|
loading: selectLoadingForUri(state, props),
|
2017-06-29 09:44:34 +02:00
|
|
|
claimIsMine: selectClaimForUriIsMine(state, props),
|
2017-06-06 23:19:12 +02:00
|
|
|
});
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
return select;
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|
2017-04-29 11:50:29 +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)),
|
2017-04-29 19:02:25 +02:00
|
|
|
closeModal: () => dispatch(doCloseModal()),
|
2017-06-06 23:19:12 +02:00
|
|
|
openInFolder: fileInfo => dispatch(doOpenFileInFolder(fileInfo)),
|
|
|
|
openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)),
|
2017-06-29 09:44:34 +02:00
|
|
|
deleteFile: (fileInfo, deleteFromComputer, abandonClaim) => {
|
2017-06-06 23:19:12 +02:00
|
|
|
dispatch(doHistoryBack());
|
2017-06-29 09:44:34 +02:00
|
|
|
dispatch(doDeleteFile(fileInfo, deleteFromComputer, abandonClaim));
|
2017-05-19 01:14:26 +02:00
|
|
|
},
|
2017-06-06 23:19:12 +02:00
|
|
|
openModal: modal => dispatch(doOpenModal(modal)),
|
|
|
|
startDownload: uri => dispatch(doPurchaseUri(uri, "affirmPurchase")),
|
|
|
|
loadVideo: uri => dispatch(doLoadVideo(uri)),
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default connect(makeSelect, perform)(FileActions);
|