From 2bb5f9acc6dcf22db820812bcd8c239584362c7d Mon Sep 17 00:00:00 2001
From: 6ea86b96 <6ea86b96@gmail.com>
Date: Fri, 26 May 2017 22:36:18 +0400
Subject: [PATCH 1/7] Fix playing videos that were deleted and require no cost
info
---
ui/js/actions/content.js | 21 +++++++++------------
ui/js/component/video/view.jsx | 4 +++-
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js
index 023a3c65a..e09bd5ea1 100644
--- a/ui/js/actions/content.js
+++ b/ui/js/actions/content.js
@@ -214,22 +214,16 @@ export function doPurchaseUri(uri) {
const state = getState()
const balance = selectBalance(state)
const fileInfo = selectFileInfoForUri(state, { uri })
- const costInfo = selectCostInfoForUri(state, { uri })
const downloadingByUri = selectUrisDownloading(state)
const alreadyDownloading = !!downloadingByUri[uri]
- const { cost } = costInfo
- // BUG if you delete a file from the file system system you're going to be
- // asked to pay for it again. We need to check if the file is in the blobs
- // here and then dispatch doLoadVideo() which will reconstruct it again from
- // the blobs. Or perhaps there's another way to see if a file was already
- // purchased?
+ // we already fully downloaded the file.
+ if (fileInfo && fileInfo.completed) {
+ // If written_bytes is false that means the user has deleted/moved the
+ // file manually on their file system, so we need to dispatch a
+ // 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()
}
@@ -238,6 +232,9 @@ export function doPurchaseUri(uri) {
return Promise.resolve()
}
+ const costInfo = selectCostInfoForUri(state, { uri })
+ const { cost } = costInfo
+
// the file is free or we have partially downloaded it
if (cost <= 0.01 || (fileInfo && fileInfo.download_directory)) {
dispatch(doLoadVideo(uri))
diff --git a/ui/js/component/video/view.jsx b/ui/js/component/video/view.jsx
index 081396cab..0bf7dc0bb 100644
--- a/ui/js/component/video/view.jsx
+++ b/ui/js/component/video/view.jsx
@@ -43,9 +43,11 @@ class VideoPlayButton extends React.Component {
}
*/
+ const disabled = isLoading || fileInfo === undefined || (fileInfo === null && (!costInfo || costInfo.cost === undefined))
+
return (
Date: Sun, 28 May 2017 15:35:11 +0400
Subject: [PATCH 2/7] Turns out that batchActions doesn't play nicely with
thunk
---
ui/js/main.js | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/ui/js/main.js b/ui/js/main.js
index 04027b6f2..969ecfdc0 100644
--- a/ui/js/main.js
+++ b/ui/js/main.js
@@ -8,7 +8,6 @@ import SplashScreen from 'component/splash.js';
import SnackBar from 'component/snackBar';
import {AuthOverlay} from 'component/auth.js';
import { Provider } from 'react-redux';
-import batchActions from 'util/batchActions'
import store from 'store.js';
import {
doChangePath,
@@ -79,12 +78,10 @@ var init = function() {
window.sessionStorage.setItem('loaded', 'y'); //once we've made it here once per session, we don't need to show splash again
const actions = []
- actions.push(doDaemonReady())
- actions.push(doChangePath('/discover'))
- actions.push(doFetchDaemonSettings())
- actions.push(doFileList())
-
- app.store.dispatch(batchActions(actions))
+ app.store.dispatch(doDaemonReady())
+ app.store.dispatch(doChangePath('/discover'))
+ app.store.dispatch(doFetchDaemonSettings())
+ app.store.dispatch(doFileList())
ReactDOM.render(
{ lbryio.enabled ? : '' }
, canvas)
}
From 862d711391311a0942227268b407c19c77787361 Mon Sep 17 00:00:00 2001
From: 6ea86b96 <6ea86b96@gmail.com>
Date: Sun, 28 May 2017 17:38:36 +0400
Subject: [PATCH 3/7] Add a message for when we're reconstructing a
moved/deleted file before playback
---
ui/js/component/video/view.jsx | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ui/js/component/video/view.jsx b/ui/js/component/video/view.jsx
index 0bf7dc0bb..760a728ad 100644
--- a/ui/js/component/video/view.jsx
+++ b/ui/js/component/video/view.jsx
@@ -101,7 +101,9 @@ class Video extends React.Component {
let loadStatusMessage = ''
- if (isLoading) {
+ if(fileInfo && fileInfo.completed && !fileInfo.written_bytes) {
+ loadStatusMessage = "It looks like you deleted or moved this file. We're rebuilding it now. It will only take a few seconds."
+ } else if (isLoading) {
loadStatusMessage = "Requesting stream... it may sit here for like 15-20 seconds in a really awkward way... we're working on it"
} else if (isDownloading) {
loadStatusMessage = "Downloading stream... not long left now!"
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 4/7] 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 {