From 37344b3517aac2d2f38c938fb5019f83bb1ad975 Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Sun, 28 May 2017 18:24:10 +0400 Subject: [PATCH] Stop blowing up if user attempts to download before cost info fetched --- ui/js/component/fileActions/index.js | 7 ++++++- ui/js/component/fileActions/view.jsx | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/js/component/fileActions/index.js b/ui/js/component/fileActions/index.js index a570cd413..e9dc10705 100644 --- a/ui/js/component/fileActions/index.js +++ b/ui/js/component/fileActions/index.js @@ -16,6 +16,9 @@ import { import { selectCurrentModal, } from 'selectors/app' +import { + makeSelectCostInfoForUri, +} from 'selectors/cost_info' import { doCloseModal, doOpenModal, @@ -39,6 +42,7 @@ const makeSelect = () => { const selectFileInfoForUri = makeSelectFileInfoForUri() const selectIsAvailableForUri = makeSelectIsAvailableForUri() const selectDownloadingForUri = makeSelectDownloadingForUri() + const selectCostInfoForUri = makeSelectCostInfoForUri() const select = (state, props) => ({ fileInfo: selectFileInfoForUri(state, props), @@ -46,6 +50,7 @@ const makeSelect = () => { platform: selectPlatform(state), modal: selectCurrentModal(state), downloading: selectDownloadingForUri(state, props), + costInfo: selectCostInfoForUri(state, props), }) return select @@ -62,7 +67,7 @@ const perform = (dispatch) => ({ }, openModal: (modal) => dispatch(doOpenModal(modal)), startDownload: (uri) => dispatch(doPurchaseUri(uri)), - loadVideo: (uri) => dispatch(doLoadVideo(uri)) + loadVideo: (uri) => dispatch(doLoadVideo(uri)), }) export default connect(makeSelect, perform)(FileActions) \ No newline at end of file diff --git a/ui/js/component/fileActions/view.jsx b/ui/js/component/fileActions/view.jsx index 4924d059d..7f3c1d75c 100644 --- a/ui/js/component/fileActions/view.jsx +++ b/ui/js/component/fileActions/view.jsx @@ -62,6 +62,7 @@ class FileActions extends React.Component { openModal, closeModal, startDownload, + costInfo, } = this.props const deleteChecked = this.state.deleteChecked, @@ -99,8 +100,11 @@ class FileActions extends React.Component { } else if (fileInfo === null && !downloading) { - - content = { startDownload(uri) } } />; + if (!costInfo) { + content = + } else { + content = { startDownload(uri) } } />; + } } else if (fileInfo && fileInfo.download_path) { content = openInShell(fileInfo)} />;