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 const { cost } = costInfo
// TODO does > 0 mean the file is downloaded? We don't have the total_bytes // 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) { if (fileInfo.written_bytes > 0) {
console.debug('this file is already downloaded')
dispatch(doPlayVideo(uri)) dispatch(doPlayVideo(uri))
} else { } else {
if (cost > balance) { if (cost > balance) {

View file

@ -16,12 +16,8 @@ import {
selectLoadingCurrentUri, selectLoadingCurrentUri,
selectCurrentUriFileReadyToPlay, selectCurrentUriFileReadyToPlay,
selectCurrentUriIsPlaying, selectCurrentUriIsPlaying,
selectCurrentUriFileInfo,
selectDownloadingCurrentUri, selectDownloadingCurrentUri,
} from 'selectors/file_info' } from 'selectors/content'
import {
selectCurrentUriCostInfo,
} from 'selectors/cost_info'
import Video from './view' import Video from './view'
const select = (state) => ({ const select = (state) => ({
@ -30,11 +26,12 @@ const select = (state) => ({
modal: selectCurrentModal(state), modal: selectCurrentModal(state),
isLoading: selectLoadingCurrentUri(state), isLoading: selectLoadingCurrentUri(state),
readyToPlay: selectCurrentUriFileReadyToPlay(state), readyToPlay: selectCurrentUriFileReadyToPlay(state),
isDownloading: selectDownloadingCurrentUri(state), isDownloading: <selectDownloadingCurre></selectDownloadingCurre>ntUri(state),
}) })
const perform = (dispatch) => ({ const perform = (dispatch) => ({
loadVideo: () => dispatch(doLoadVideo()), loadVideo: () => dispatch(doLoadVideo()),
play: () => dispatch(doPlayVideo()),
watchVideo: (elem) => dispatch(doWatchVideo()), watchVideo: (elem) => dispatch(doWatchVideo()),
closeModal: () => dispatch(doCloseModal()), closeModal: () => dispatch(doCloseModal()),
}) })

View file

@ -8,6 +8,7 @@ const defaultState = {
drawerOpen: sessionStorage.getItem('drawerOpen') || true, drawerOpen: sessionStorage.getItem('drawerOpen') || true,
upgradeSkipped: sessionStorage.getItem('upgradeSkipped'), upgradeSkipped: sessionStorage.getItem('upgradeSkipped'),
daemonReady: false, daemonReady: false,
platform: window.navigator.platform,
} }
reducers[types.NAVIGATE] = function(state, action) { reducers[types.NAVIGATE] = function(state, action) {

View file

@ -214,12 +214,17 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) {
} = action.data } = action.data
const newDownloading = Object.assign({}, state.downloading) const newDownloading = Object.assign({}, state.downloading)
const newByUri = Object.assign({}, newDownloading.byUri) const newByUri = Object.assign({}, newDownloading.byUri)
const newLoading = Object.assign({}, state.loading)
const newLoadingByUri = Object.assign({}, newLoading.byUri)
newByUri[uri] = true newByUri[uri] = true
newDownloading.byUri = newByUri newDownloading.byUri = newByUri
delete newLoadingByUri[uri]
newLoading.byUri = newLoadingByUri
return Object.assign({}, state, { return Object.assign({}, state, {
downloading: newDownloading, downloading: newDownloading,
loading: newLoading,
}) })
} }

View file

@ -209,7 +209,23 @@ export const selectLoadingByUri = createSelector(
export const selectLoadingCurrentUri = createSelector( export const selectLoadingCurrentUri = createSelector(
selectLoadingByUri, selectLoadingByUri,
selectCurrentUri, 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( export const shouldFetchPublishedContent = createSelector(