2017-04-29 11:50:29 +02:00
|
|
|
import React from 'react'
|
|
|
|
import {
|
|
|
|
connect,
|
|
|
|
} from 'react-redux'
|
|
|
|
import {
|
2017-04-29 19:02:25 +02:00
|
|
|
selectPlatform,
|
2017-04-29 11:50:29 +02:00
|
|
|
} from 'selectors/app'
|
2017-04-29 19:02:25 +02:00
|
|
|
import {
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectDownloadingForUri,
|
|
|
|
makeSelectLoadingForUri,
|
|
|
|
} from 'selectors/file_info'
|
|
|
|
import {
|
2017-05-15 05:50:59 +02:00
|
|
|
makeSelectIsAvailableForUri,
|
2017-04-29 19:02:25 +02:00
|
|
|
} from 'selectors/availability'
|
|
|
|
import {
|
|
|
|
selectCurrentModal,
|
|
|
|
} from 'selectors/app'
|
|
|
|
import {
|
|
|
|
doCloseModal,
|
|
|
|
doOpenModal,
|
|
|
|
} from 'actions/app'
|
2017-05-15 05:50:59 +02:00
|
|
|
import {
|
|
|
|
doFetchAvailability
|
|
|
|
} from 'actions/availability'
|
2017-04-29 19:02:25 +02:00
|
|
|
import {
|
|
|
|
doOpenFileInShell,
|
|
|
|
doOpenFileInFolder,
|
|
|
|
doDeleteFile,
|
|
|
|
} from 'actions/file_info'
|
|
|
|
import {
|
|
|
|
doWatchVideo,
|
2017-05-01 06:51:19 +02:00
|
|
|
doLoadVideo,
|
2017-04-29 19:02:25 +02:00
|
|
|
} from 'actions/content'
|
2017-04-29 11:50:29 +02:00
|
|
|
import FileActions from './view'
|
|
|
|
|
2017-04-29 19:02:25 +02:00
|
|
|
const makeSelect = () => {
|
|
|
|
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
2017-05-15 05:50:59 +02:00
|
|
|
const selectIsAvailableForUri = makeSelectIsAvailableForUri()
|
2017-04-29 19:02:25 +02:00
|
|
|
const selectDownloadingForUri = makeSelectDownloadingForUri()
|
|
|
|
|
|
|
|
const select = (state, props) => ({
|
|
|
|
fileInfo: selectFileInfoForUri(state, props),
|
2017-05-15 05:50:59 +02:00
|
|
|
isAvailable: selectIsAvailableForUri(state, props),
|
2017-04-29 19:02:25 +02:00
|
|
|
platform: selectPlatform(state),
|
|
|
|
modal: selectCurrentModal(state),
|
|
|
|
downloading: selectDownloadingForUri(state, props),
|
|
|
|
})
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2017-04-29 19:02:25 +02:00
|
|
|
return select
|
2017-04-29 11:50:29 +02:00
|
|
|
}
|
|
|
|
|
2017-04-29 19:02:25 +02:00
|
|
|
const perform = (dispatch) => ({
|
2017-05-15 05:50:59 +02:00
|
|
|
checkAvailability: (uri) => dispatch(doFetchAvailability(uri)),
|
2017-04-29 19:02:25 +02:00
|
|
|
closeModal: () => dispatch(doCloseModal()),
|
|
|
|
openInFolder: (fileInfo) => dispatch(doOpenFileInFolder(fileInfo)),
|
|
|
|
openInShell: (fileInfo) => dispatch(doOpenFileInShell(fileInfo)),
|
|
|
|
deleteFile: (fileInfo, deleteFromComputer) => dispatch(doDeleteFile(fileInfo, deleteFromComputer)),
|
|
|
|
openModal: (modal) => dispatch(doOpenModal(modal)),
|
2017-05-15 05:50:59 +02:00
|
|
|
startDownload: (uri) => dispatch(doWatchVideo(uri)),
|
|
|
|
loadVideo: (uri) => dispatch(doLoadVideo(uri))
|
2017-04-29 19:02:25 +02:00
|
|
|
})
|
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
export default connect(makeSelect, perform)(FileActions)
|