Merge pull request #145 from 6ea86b96/bug/no-cost-info-required
Fix playing videos that were deleted and require no cost info
This commit is contained in:
commit
89c4402d67
2 changed files with 12 additions and 13 deletions
|
@ -214,22 +214,16 @@ export function doPurchaseUri(uri) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const balance = selectBalance(state)
|
const balance = selectBalance(state)
|
||||||
const fileInfo = selectFileInfoForUri(state, { uri })
|
const fileInfo = selectFileInfoForUri(state, { uri })
|
||||||
const costInfo = selectCostInfoForUri(state, { uri })
|
|
||||||
const downloadingByUri = selectUrisDownloading(state)
|
const downloadingByUri = selectUrisDownloading(state)
|
||||||
const alreadyDownloading = !!downloadingByUri[uri]
|
const alreadyDownloading = !!downloadingByUri[uri]
|
||||||
const { cost } = costInfo
|
|
||||||
|
|
||||||
// BUG if you delete a file from the file system system you're going to be
|
// we already fully downloaded the file.
|
||||||
// asked to pay for it again. We need to check if the file is in the blobs
|
if (fileInfo && fileInfo.completed) {
|
||||||
// here and then dispatch doLoadVideo() which will reconstruct it again from
|
// If written_bytes is false that means the user has deleted/moved the
|
||||||
// the blobs. Or perhaps there's another way to see if a file was already
|
// file manually on their file system, so we need to dispatch a
|
||||||
// purchased?
|
// doLoadVideo action to reconstruct the file from the blobs
|
||||||
|
if (!fileInfo.written_bytes) dispatch(doLoadVideo(uri))
|
||||||
|
|
||||||
// we already fully downloaded the file. If completed is true but
|
|
||||||
// writtenBytes is false then we downloaded it before but deleted it again,
|
|
||||||
// which means it needs to be reconstructed from the blobs by dispatching
|
|
||||||
// doLoadVideo.
|
|
||||||
if (fileInfo && fileInfo.completed && !!fileInfo.writtenBytes) {
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +232,9 @@ export function doPurchaseUri(uri) {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const costInfo = selectCostInfoForUri(state, { uri })
|
||||||
|
const { cost } = costInfo
|
||||||
|
|
||||||
// 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 && fileInfo.download_directory)) {
|
if (cost <= 0.01 || (fileInfo && fileInfo.download_directory)) {
|
||||||
dispatch(doLoadVideo(uri))
|
dispatch(doLoadVideo(uri))
|
||||||
|
|
|
@ -43,9 +43,11 @@ class VideoPlayButton extends React.Component {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const disabled = isLoading || fileInfo === undefined || (fileInfo === null && (!costInfo || costInfo.cost === undefined))
|
||||||
|
|
||||||
return (<div>
|
return (<div>
|
||||||
<Link button={ button ? button : null }
|
<Link button={ button ? button : null }
|
||||||
disabled={isLoading || fileInfo === undefined || (fileInfo === null && (!costInfo || costInfo.cost === undefined))}
|
disabled={disabled}
|
||||||
label={label ? label : ""}
|
label={label ? label : ""}
|
||||||
className="video__play-button"
|
className="video__play-button"
|
||||||
icon="icon-play"
|
icon="icon-play"
|
||||||
|
|
Loading…
Add table
Reference in a new issue