diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index f26bd045a..0cd0d529e 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -275,11 +275,7 @@ export function doWatchVideo() { const { cost } = costInfo // TODO does > 0 mean the file is downloaded? We don't have the total_bytes - console.log(fileInfo) - console.log(fileInfo.written_bytes) - console.log('wtf') if (fileInfo.written_bytes > 0) { - console.debug('this file is already downloaded') dispatch(doPlayVideo(uri)) } else { if (cost > balance) { diff --git a/ui/js/component/video/index.js b/ui/js/component/video/index.js index 94978f702..667b7a883 100644 --- a/ui/js/component/video/index.js +++ b/ui/js/component/video/index.js @@ -16,12 +16,8 @@ import { selectLoadingCurrentUri, selectCurrentUriFileReadyToPlay, selectCurrentUriIsPlaying, - selectCurrentUriFileInfo, selectDownloadingCurrentUri, -} from 'selectors/file_info' -import { - selectCurrentUriCostInfo, -} from 'selectors/cost_info' +} from 'selectors/content' import Video from './view' const select = (state) => ({ @@ -30,11 +26,12 @@ const select = (state) => ({ modal: selectCurrentModal(state), isLoading: selectLoadingCurrentUri(state), readyToPlay: selectCurrentUriFileReadyToPlay(state), - isDownloading: selectDownloadingCurrentUri(state), + isDownloading: ntUri(state), }) const perform = (dispatch) => ({ loadVideo: () => dispatch(doLoadVideo()), + play: () => dispatch(doPlayVideo()), watchVideo: (elem) => dispatch(doWatchVideo()), closeModal: () => dispatch(doCloseModal()), }) diff --git a/ui/js/reducers/app.js b/ui/js/reducers/app.js index ffc13cd74..855330de3 100644 --- a/ui/js/reducers/app.js +++ b/ui/js/reducers/app.js @@ -8,6 +8,7 @@ const defaultState = { drawerOpen: sessionStorage.getItem('drawerOpen') || true, upgradeSkipped: sessionStorage.getItem('upgradeSkipped'), daemonReady: false, + platform: window.navigator.platform, } reducers[types.NAVIGATE] = function(state, action) { diff --git a/ui/js/reducers/content.js b/ui/js/reducers/content.js index 720877177..9d70bd438 100644 --- a/ui/js/reducers/content.js +++ b/ui/js/reducers/content.js @@ -214,12 +214,17 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) { } = action.data const newDownloading = Object.assign({}, state.downloading) const newByUri = Object.assign({}, newDownloading.byUri) + const newLoading = Object.assign({}, state.loading) + const newLoadingByUri = Object.assign({}, newLoading.byUri) newByUri[uri] = true newDownloading.byUri = newByUri + delete newLoadingByUri[uri] + newLoading.byUri = newLoadingByUri return Object.assign({}, state, { downloading: newDownloading, + loading: newLoading, }) } diff --git a/ui/js/selectors/content.js b/ui/js/selectors/content.js index 274d98d3d..50e4facf2 100644 --- a/ui/js/selectors/content.js +++ b/ui/js/selectors/content.js @@ -209,7 +209,23 @@ export const selectLoadingByUri = createSelector( export const selectLoadingCurrentUri = createSelector( selectLoadingByUri, selectCurrentUri, - (byUri, uri) => byUri[uri] + (byUri, uri) => !!byUri[uri] +) + +export const selectDownloading = createSelector( + _selectState, + (state) => state.downloading || {} +) + +export const selectDownloadingByUri = createSelector( + selectDownloading, + (downloading) => downloading.byUri || {} +) + +export const selectDownloadingCurrentUri = createSelector( + selectCurrentUri, + selectDownloadingByUri, + (uri, byUri) => byUri[uri] ) export const shouldFetchPublishedContent = createSelector(