Fix purchasing from file actions and allow content to be watched when being
downloaded from file actions download link
This commit is contained in:
parent
bef2f87efd
commit
1d549ff258
5 changed files with 38 additions and 6 deletions
|
@ -13,6 +13,7 @@ import {
|
|||
} from 'selectors/content'
|
||||
import {
|
||||
selectCurrentUriFileInfo,
|
||||
selectDownloadingByUri,
|
||||
} from 'selectors/file_info'
|
||||
import {
|
||||
selectCurrentUriCostInfo,
|
||||
|
@ -249,6 +250,8 @@ export function doWatchVideo() {
|
|||
const balance = selectBalance(state)
|
||||
const fileInfo = selectCurrentUriFileInfo(state)
|
||||
const costInfo = selectCurrentUriCostInfo(state)
|
||||
const downloadingByUri = selectDownloadingByUri(state)
|
||||
const alreadyDownloading = !!downloadingByUri[uri]
|
||||
const { cost } = costInfo
|
||||
|
||||
// we already fully downloaded the file
|
||||
|
@ -256,6 +259,11 @@ export function doWatchVideo() {
|
|||
return Promise.resolve()
|
||||
}
|
||||
|
||||
// we are already downloading the file
|
||||
if (alreadyDownloading) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
// the file is free or we have partially downloaded it
|
||||
if (cost <= 0.01 || fileInfo.download_directory) {
|
||||
dispatch(doLoadVideo())
|
||||
|
|
|
@ -30,6 +30,7 @@ import {
|
|||
} from 'actions/file_info'
|
||||
import {
|
||||
doWatchVideo,
|
||||
doLoadVideo,
|
||||
} from 'actions/content'
|
||||
import FileActions from './view'
|
||||
|
||||
|
@ -58,10 +59,10 @@ const perform = (dispatch) => ({
|
|||
closeModal: () => dispatch(doCloseModal()),
|
||||
openInFolder: (fileInfo) => dispatch(doOpenFileInFolder(fileInfo)),
|
||||
openInShell: (fileInfo) => dispatch(doOpenFileInShell(fileInfo)),
|
||||
affirmPurchase: () => console.log('affirm purchase'),
|
||||
deleteFile: (fileInfo, deleteFromComputer) => dispatch(doDeleteFile(fileInfo, deleteFromComputer)),
|
||||
openModal: (modal) => dispatch(doOpenModal(modal)),
|
||||
downloadClick: () => dispatch(doWatchVideo()),
|
||||
loadVideo: () => dispatch(doLoadVideo())
|
||||
})
|
||||
|
||||
export default connect(makeSelect, perform)(FileActions)
|
||||
|
|
|
@ -23,6 +23,11 @@ class FileActionsRow extends React.Component {
|
|||
})
|
||||
}
|
||||
|
||||
onAffirmPurchase() {
|
||||
this.props.closeModal()
|
||||
this.props.loadVideo()
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
fileInfo,
|
||||
|
@ -85,7 +90,7 @@ class FileActionsRow extends React.Component {
|
|||
<DropDownMenuItem key={1} onClick={() => openModal('confirmRemove')} label="Remove..." />
|
||||
</DropDownMenu> : '' }
|
||||
<Modal type="confirm" isOpen={modal == 'affirmPurchase'}
|
||||
contentLabel="Confirm Purchase" onConfirmed={affirmPurchase} onAborted={closeModal}>
|
||||
contentLabel="Confirm Purchase" onConfirmed={this.onAffirmPurchase.bind(this)} onAborted={closeModal}>
|
||||
Are you sure you'd like to buy <strong>{title}</strong> for <strong><FilePrice uri={uri} look="plain" /></strong> credits?
|
||||
</Modal>
|
||||
<Modal isOpen={modal == 'notEnoughCredits'} contentLabel="Not enough credits"
|
||||
|
|
|
@ -88,9 +88,9 @@ class FileTileStream extends React.Component {
|
|||
{ !this.props.hidePrice
|
||||
? <FilePrice uri={this.props.uri} />
|
||||
: null}
|
||||
<div className="meta"><a href={'?show=' + this.props.uri}>{uri}</a></div>
|
||||
<div className="meta"><a href="#" onClick={() => navigate(`show=${uri}`)}>{uri}</a></div>
|
||||
<h3>
|
||||
<a href={'?show=' + uri} title={title}>
|
||||
<a href="#" onClick={() => navigate(`show=${uri}`)} title={title}>
|
||||
<TruncatedText lines={1}>
|
||||
{title}
|
||||
</TruncatedText>
|
||||
|
@ -114,7 +114,7 @@ class FileTileStream extends React.Component {
|
|||
? <div className='card-overlay'>
|
||||
<p>
|
||||
This content is Not Safe For Work.
|
||||
To view adult content, please change your <Link className="button-text" href="?settings" label="Settings" />.
|
||||
To view adult content, please change your <Link className="button-text" href="#" onClick={() => navigate('settings')} label="Settings" />.
|
||||
</p>
|
||||
</div>
|
||||
: null}
|
||||
|
|
|
@ -2,6 +2,24 @@ import React from 'react'
|
|||
import {
|
||||
connect
|
||||
} from 'react-redux'
|
||||
import {
|
||||
selectFetchingPublishedContent,
|
||||
} from 'selectors/content'
|
||||
import {
|
||||
selectPublishedFileInfo,
|
||||
} from 'selectors/file_info'
|
||||
import {
|
||||
doNavigate,
|
||||
} from 'actions/app'
|
||||
import FileListPublished from './view'
|
||||
|
||||
export default connect()(FileListPublished)
|
||||
const select = (state) => ({
|
||||
publishedContent: selectPublishedFileInfo(state),
|
||||
fetching: selectFetchingPublishedContent(state),
|
||||
})
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
navigate: (path) => dispatch(doNavigate(path)),
|
||||
})
|
||||
|
||||
export default connect(select, perform)(FileListPublished)
|
||||
|
|
Loading…
Reference in a new issue