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'
|
} from 'selectors/content'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriFileInfo,
|
selectCurrentUriFileInfo,
|
||||||
|
selectDownloadingByUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriCostInfo,
|
selectCurrentUriCostInfo,
|
||||||
|
@ -249,6 +250,8 @@ export function doWatchVideo() {
|
||||||
const balance = selectBalance(state)
|
const balance = selectBalance(state)
|
||||||
const fileInfo = selectCurrentUriFileInfo(state)
|
const fileInfo = selectCurrentUriFileInfo(state)
|
||||||
const costInfo = selectCurrentUriCostInfo(state)
|
const costInfo = selectCurrentUriCostInfo(state)
|
||||||
|
const downloadingByUri = selectDownloadingByUri(state)
|
||||||
|
const alreadyDownloading = !!downloadingByUri[uri]
|
||||||
const { cost } = costInfo
|
const { cost } = costInfo
|
||||||
|
|
||||||
// we already fully downloaded the file
|
// we already fully downloaded the file
|
||||||
|
@ -256,6 +259,11 @@ export function doWatchVideo() {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we are already downloading the file
|
||||||
|
if (alreadyDownloading) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
// the file is free or we have partially downloaded it
|
// the file is free or we have partially downloaded it
|
||||||
if (cost <= 0.01 || fileInfo.download_directory) {
|
if (cost <= 0.01 || fileInfo.download_directory) {
|
||||||
dispatch(doLoadVideo())
|
dispatch(doLoadVideo())
|
||||||
|
|
|
@ -30,6 +30,7 @@ import {
|
||||||
} from 'actions/file_info'
|
} from 'actions/file_info'
|
||||||
import {
|
import {
|
||||||
doWatchVideo,
|
doWatchVideo,
|
||||||
|
doLoadVideo,
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
import FileActions from './view'
|
import FileActions from './view'
|
||||||
|
|
||||||
|
@ -58,10 +59,10 @@ const perform = (dispatch) => ({
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
closeModal: () => dispatch(doCloseModal()),
|
||||||
openInFolder: (fileInfo) => dispatch(doOpenFileInFolder(fileInfo)),
|
openInFolder: (fileInfo) => dispatch(doOpenFileInFolder(fileInfo)),
|
||||||
openInShell: (fileInfo) => dispatch(doOpenFileInShell(fileInfo)),
|
openInShell: (fileInfo) => dispatch(doOpenFileInShell(fileInfo)),
|
||||||
affirmPurchase: () => console.log('affirm purchase'),
|
|
||||||
deleteFile: (fileInfo, deleteFromComputer) => dispatch(doDeleteFile(fileInfo, deleteFromComputer)),
|
deleteFile: (fileInfo, deleteFromComputer) => dispatch(doDeleteFile(fileInfo, deleteFromComputer)),
|
||||||
openModal: (modal) => dispatch(doOpenModal(modal)),
|
openModal: (modal) => dispatch(doOpenModal(modal)),
|
||||||
downloadClick: () => dispatch(doWatchVideo()),
|
downloadClick: () => dispatch(doWatchVideo()),
|
||||||
|
loadVideo: () => dispatch(doLoadVideo())
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(makeSelect, perform)(FileActions)
|
export default connect(makeSelect, perform)(FileActions)
|
||||||
|
|
|
@ -23,6 +23,11 @@ class FileActionsRow extends React.Component {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAffirmPurchase() {
|
||||||
|
this.props.closeModal()
|
||||||
|
this.props.loadVideo()
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
@ -85,7 +90,7 @@ class FileActionsRow extends React.Component {
|
||||||
<DropDownMenuItem key={1} onClick={() => openModal('confirmRemove')} label="Remove..." />
|
<DropDownMenuItem key={1} onClick={() => openModal('confirmRemove')} label="Remove..." />
|
||||||
</DropDownMenu> : '' }
|
</DropDownMenu> : '' }
|
||||||
<Modal type="confirm" isOpen={modal == 'affirmPurchase'}
|
<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?
|
Are you sure you'd like to buy <strong>{title}</strong> for <strong><FilePrice uri={uri} look="plain" /></strong> credits?
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal isOpen={modal == 'notEnoughCredits'} contentLabel="Not enough credits"
|
<Modal isOpen={modal == 'notEnoughCredits'} contentLabel="Not enough credits"
|
||||||
|
|
|
@ -88,9 +88,9 @@ class FileTileStream extends React.Component {
|
||||||
{ !this.props.hidePrice
|
{ !this.props.hidePrice
|
||||||
? <FilePrice uri={this.props.uri} />
|
? <FilePrice uri={this.props.uri} />
|
||||||
: null}
|
: 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>
|
<h3>
|
||||||
<a href={'?show=' + uri} title={title}>
|
<a href="#" onClick={() => navigate(`show=${uri}`)} title={title}>
|
||||||
<TruncatedText lines={1}>
|
<TruncatedText lines={1}>
|
||||||
{title}
|
{title}
|
||||||
</TruncatedText>
|
</TruncatedText>
|
||||||
|
@ -114,7 +114,7 @@ class FileTileStream extends React.Component {
|
||||||
? <div className='card-overlay'>
|
? <div className='card-overlay'>
|
||||||
<p>
|
<p>
|
||||||
This content is Not Safe For Work.
|
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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
: null}
|
: null}
|
||||||
|
|
|
@ -2,6 +2,24 @@ import React from 'react'
|
||||||
import {
|
import {
|
||||||
connect
|
connect
|
||||||
} from 'react-redux'
|
} from 'react-redux'
|
||||||
|
import {
|
||||||
|
selectFetchingPublishedContent,
|
||||||
|
} from 'selectors/content'
|
||||||
|
import {
|
||||||
|
selectPublishedFileInfo,
|
||||||
|
} from 'selectors/file_info'
|
||||||
|
import {
|
||||||
|
doNavigate,
|
||||||
|
} from 'actions/app'
|
||||||
import FileListPublished from './view'
|
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