Skip to content

Commit

Permalink
Fix videos on dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Nesiu committed Jun 19, 2019
1 parent d338841 commit f5bd071
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions dispatch/static/manager/src/js/pages/Videos/VideoIndexPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from 'react-redux'
import { replace } from 'react-router-redux'

import ItemIndexPage from '../ItemIndexPage'
import videosActions from '../../actions/VideosActions'
import VideosActions from '../../actions/VideosActions'
import { humanizeDatetime } from '../../util/helpers'
import { AuthorFilterInput, TagsFilterInput} from '../../components/inputs/filters'
import PersonsActions from '../../actions/PersonsActions'
Expand All @@ -22,23 +22,32 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => {
return {
listListItems: (token, query) => {
dispatch(PersonsActions.list(token, query))
dispatch(videosActions.list(token, query))
VideosActions.list(token, query).payload.then((videos) => {
const personIds = [...new Set(Object.values(videos.data.entities.videos).map(video =>
video.authors[0].person
))]

personIds.forEach(personId => {
dispatch(PersonsActions.get(token, personId))
})

dispatch(VideosActions.list(token, query))
})
},
toggleListItem: (videoId) => {
dispatch(videosActions.toggle(videoId))
dispatch(VideosActions.toggle(videoId))
},
toggleAllListItems: (videoIds) => {
dispatch(videosActions.toggleAll(videoIds))
dispatch(VideosActions.toggleAll(videoIds))
},
clearSelectedListItems: () => {
dispatch(videosActions.clearSelected())
dispatch(VideosActions.clearSelected())
},
clearListItems: () => {
dispatch(videosActions.clearAll())
dispatch(VideosActions.clearAll())
},
deleteListItems: (token, videoIds, goDownPage) => {
dispatch(videosActions.deleteMany(token, videoIds))
dispatch(VideosActions.deleteMany(token, videoIds))
if (goDownPage) {
dispatch(replace({
pathname: '/videos/',
Expand All @@ -49,7 +58,7 @@ const mapDispatchToProps = (dispatch) => {
}
},
searchVideos: (author, tags, query) => {
dispatch(videosActions.search(author, tags, query))
dispatch(VideosActions.search(author, tags, query))
}
}
}
Expand Down

0 comments on commit f5bd071

Please sign in to comment.