Redux #115

Merged
6ea86b96 merged 57 commits from redux into redux 2017-05-05 22:55:12 +02:00
5 changed files with 26 additions and 11 deletions
Showing only changes of commit e0b78368ab - Show all commits

View file

@ -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) {

View file

@ -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: <selectDownloadingCurre></selectDownloadingCurre>ntUri(state),
})
const perform = (dispatch) => ({
loadVideo: () => dispatch(doLoadVideo()),
play: () => dispatch(doPlayVideo()),
watchVideo: (elem) => dispatch(doWatchVideo()),
closeModal: () => dispatch(doCloseModal()),
})

View file

@ -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) {

View file

@ -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,
})
}

View file

@ -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(