Stop blowing up if user attempts to download before cost info fetched
This commit is contained in:
parent
89c4402d67
commit
37344b3517
2 changed files with 12 additions and 3 deletions
|
@ -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)
|
|
@ -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 {
|
|||
</div>
|
||||
|
||||
} else if (fileInfo === null && !downloading) {
|
||||
|
||||
if (!costInfo) {
|
||||
content = <BusyMessage message="Fetching cost info" />
|
||||
} else {
|
||||
content = <Link button="text" label="Download" icon="icon-download" onClick={() => { startDownload(uri) } } />;
|
||||
}
|
||||
|
||||
} else if (fileInfo && fileInfo.download_path) {
|
||||
content = <Link label="Open" button="text" icon="icon-folder-open" onClick={() => openInShell(fileInfo)} />;
|
||||
|
|
Loading…
Reference in a new issue