From 9ba4af9d7d3e1064245588269d037b36f9ac2378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Tue, 23 May 2017 22:07:19 +0200 Subject: [PATCH] Split actions to separate file Only use the necessary actions for each component --- src/public/js/actions/actionCreators.js | 293 ---------------------- src/public/js/actions/alerts.js | 23 ++ src/public/js/actions/movies.js | 86 +++++++ src/public/js/actions/shows.js | 106 ++++++++ src/public/js/actions/torrents.js | 22 ++ src/public/js/actions/users.js | 46 ++++ src/public/js/app.js | 8 +- src/public/js/components/movies/list.js | 5 +- src/public/js/components/shows/details.js | 5 +- src/public/js/components/shows/list.js | 2 +- src/public/js/components/torrents/list.js | 2 +- src/public/js/components/users/edit.js | 22 +- src/public/js/components/users/login.js | 21 +- src/public/js/components/users/signup.js | 10 +- src/public/js/routes.js | 38 +-- 15 files changed, 359 insertions(+), 330 deletions(-) delete mode 100644 src/public/js/actions/actionCreators.js create mode 100644 src/public/js/actions/alerts.js create mode 100644 src/public/js/actions/movies.js create mode 100644 src/public/js/actions/shows.js create mode 100644 src/public/js/actions/torrents.js create mode 100644 src/public/js/actions/users.js diff --git a/src/public/js/actions/actionCreators.js b/src/public/js/actions/actionCreators.js deleted file mode 100644 index b0eef51..0000000 --- a/src/public/js/actions/actionCreators.js +++ /dev/null @@ -1,293 +0,0 @@ -import { configureAxios, request } from '../requests' - -// ====================== -// Alerts -// ====================== - -export function addAlertError(message) { - return { - type: 'ADD_ALERT_ERROR', - payload: { - message, - } - } -} - -export function addAlertOk(message) { - return { - type: 'ADD_ALERT_OK', - payload: { - message, - } - } -} - -export function dismissAlert() { - return { - type: 'DISMISS_ALERT', - } -} - -// ====================== -// Users -// ====================== - -export function userLogout() { - return { - type: 'USER_LOGOUT', - } -} - -export function loginUser(username, password) { - return request( - 'USER_LOGIN', - configureAxios().post( - '/users/login', - { - username: username, - password: password, - }, - ), - ) -} - -export function updateUser(config) { - return request( - 'USER_UPDATE', - configureAxios().post('/users/edit', config), - [ - addAlertOk("User updated"), - ], - ) -} - -export function userSignUp(config) { - return request( - 'USER_SIGNUP', - configureAxios().post('/users/signup', config) - ) -} - -export function getUserInfos() { - return request( - 'GET_USER', - configureAxios().get('/users/details') - ) -} - -// ====================== -// Movies -// ====================== - -export function updateLastMovieFetchUrl(url) { - return { - type: 'UPDATE_LAST_MOVIE_FETCH_URL', - payload: { - url: url, - }, - } -} - -export function selectMovie(imdbId) { - return { - type: 'SELECT_MOVIE', - imdbId - } -} - -export function getMovieExploreOptions() { - return request( - 'MOVIE_GET_EXPLORE_OPTIONS', - configureAxios().get('/movies/explore/options') - ) -} - -export function getMovieDetails(imdbId) { - return request( - 'MOVIE_GET_DETAILS', - configureAxios().post(`/movies/${imdbId}/refresh`) - ) -} - -export function deleteMovie(imdbId, lastFetchUrl) { - return request( - 'MOVIE_DELETE', - configureAxios().delete(`/movies/${imdbId}`), - [ - fetchMovies(lastFetchUrl), - addAlertOk("Movie deleted"), - ], - ) -} - -export function addMovieToWishlist(imdbId) { - return request( - 'MOVIE_ADD_TO_WISHLIST', - configureAxios().post(`/wishlist/movies/${imdbId}`), - [ - addAlertOk("Movie added to the wishlist"), - updateMovieWishlistStore(imdbId, true), - ], - ) -} - -export function deleteMovieFromWishlist(imdbId) { - return request( - 'MOVIE_DELETE_FROM_WISHLIST', - configureAxios().delete(`/wishlist/movies/${imdbId}`), - [ - addAlertOk("Movie deleted from the wishlist"), - updateMovieWishlistStore(imdbId, false), - ], - ) -} - -export function updateMovieWishlistStore(imdbId, wishlisted) { - return { - type: 'MOVIE_UPDATE_STORE_WISHLIST', - payload: { - imdbId, - wishlisted, - } - } -} - -export function fetchMovies(url) { - return request( - 'MOVIE_LIST_FETCH', - configureAxios().get(url), - [ - updateLastMovieFetchUrl(url), - ] - ) -} - -// ====================== -// Shows -// ====================== - -export function fetchShows(url) { - return request( - 'SHOW_LIST_FETCH', - configureAxios().get(url), - [ - updateLastShowsFetchUrl(url), - ] - ) -} - -export function getShowDetails(imdbId) { - return request( - 'SHOW_GET_DETAILS', - configureAxios().post(`/shows/${imdbId}/refresh`) - ) -} - - -export function getEpisodeDetails(imdbId, season, episode) { - return request( - 'EPISODE_GET_DETAILS', - configureAxios().post(`/shows/${imdbId}/seasons/${season}/episodes/${episode}`), - ) -} - -export function updateEpisodeDetailsStore(imdbId, season, episode) { - return { - type: 'EPISODE_GET_DETAILS', - payload: { - imdbId, - season, - episode, - }, - } -} - -export function fetchShowDetails(imdbId) { - return request( - 'SHOW_FETCH_DETAILS', - configureAxios().get(`/shows/${imdbId}`) - ) -} - -export function addShowToWishlist(imdbId, season = null, episode = null) { - return request( - 'SHOW_ADD_TO_WISHLIST', - configureAxios().post(`/wishlist/shows/${imdbId}`, { - season: season, - episode: episode, - }), - [ - addAlertOk("Show added to the wishlist"), - updateShowWishlistStore(imdbId, true, season, episode), - ], - ) -} - -export function deleteShowFromWishlist(imdbId) { - return request( - 'SHOW_DELETE_FROM_WISHLIST', - configureAxios().delete(`/wishlist/shows/${imdbId}`), - [ - addAlertOk("Show deleted from the wishlist"), - updateShowWishlistStore(imdbId, false), - ], - ) -} - -export function updateShowWishlistStore(imdbId, wishlisted, season = null, episode = null) { - return { - type: 'SHOW_UPDATE_STORE_WISHLIST', - payload: { - wishlisted: wishlisted, - imdbId, - season, - episode, - } - } -} - -export function getShowExploreOptions() { - return request( - 'SHOW_GET_EXPLORE_OPTIONS', - configureAxios().get('/shows/explore/options') - ) -} - -export function selectShow(imdbId) { - return { - type: 'SELECT_SHOW', - imdbId - } -} - -export function updateLastShowsFetchUrl(url) { - return { - type: 'UPDATE_LAST_SHOWS_FETCH_URL', - payload: { - url: url, - }, - } -} - -// ====================== -// AddTorrent -// ====================== - -export function addTorrent(url) { - return request( - 'ADD_TORRENT', - configureAxios().post('/torrents', { - url: url, - }), - [ - addAlertOk("Torrent added"), - ], - ) -} - -export function fetchTorrents() { - return request( - 'TORRENTS_FETCH', - configureAxios().get('/torrents') - ) -} diff --git a/src/public/js/actions/alerts.js b/src/public/js/actions/alerts.js new file mode 100644 index 0000000..83c1198 --- /dev/null +++ b/src/public/js/actions/alerts.js @@ -0,0 +1,23 @@ +export function addAlertError(message) { + return { + type: 'ADD_ALERT_ERROR', + payload: { + message, + } + } +} + +export function addAlertOk(message) { + return { + type: 'ADD_ALERT_OK', + payload: { + message, + } + } +} + +export function dismissAlert() { + return { + type: 'DISMISS_ALERT', + } +} diff --git a/src/public/js/actions/movies.js b/src/public/js/actions/movies.js new file mode 100644 index 0000000..e5e0d36 --- /dev/null +++ b/src/public/js/actions/movies.js @@ -0,0 +1,86 @@ +import { configureAxios, request } from '../requests' + +import { addAlertOk } from './alerts' + +export function updateLastMovieFetchUrl(url) { + return { + type: 'UPDATE_LAST_MOVIE_FETCH_URL', + payload: { + url: url, + }, + } +} + +export function selectMovie(imdbId) { + return { + type: 'SELECT_MOVIE', + imdbId + } +} + +export function getMovieExploreOptions() { + return request( + 'MOVIE_GET_EXPLORE_OPTIONS', + configureAxios().get('/movies/explore/options') + ) +} + +export function getMovieDetails(imdbId) { + return request( + 'MOVIE_GET_DETAILS', + configureAxios().post(`/movies/${imdbId}/refresh`) + ) +} + +export function deleteMovie(imdbId, lastFetchUrl) { + return request( + 'MOVIE_DELETE', + configureAxios().delete(`/movies/${imdbId}`), + [ + fetchMovies(lastFetchUrl), + addAlertOk("Movie deleted"), + ], + ) +} + +export function addMovieToWishlist(imdbId) { + return request( + 'MOVIE_ADD_TO_WISHLIST', + configureAxios().post(`/wishlist/movies/${imdbId}`), + [ + addAlertOk("Movie added to the wishlist"), + updateMovieWishlistStore(imdbId, true), + ], + ) +} + +export function deleteMovieFromWishlist(imdbId) { + return request( + 'MOVIE_DELETE_FROM_WISHLIST', + configureAxios().delete(`/wishlist/movies/${imdbId}`), + [ + addAlertOk("Movie deleted from the wishlist"), + updateMovieWishlistStore(imdbId, false), + ], + ) +} + +export function updateMovieWishlistStore(imdbId, wishlisted) { + return { + type: 'MOVIE_UPDATE_STORE_WISHLIST', + payload: { + imdbId, + wishlisted, + } + } +} + +export function fetchMovies(url) { + return request( + 'MOVIE_LIST_FETCH', + configureAxios().get(url), + [ + updateLastMovieFetchUrl(url), + ] + ) +} diff --git a/src/public/js/actions/shows.js b/src/public/js/actions/shows.js new file mode 100644 index 0000000..fc84fae --- /dev/null +++ b/src/public/js/actions/shows.js @@ -0,0 +1,106 @@ +import { configureAxios, request } from '../requests' + +import { addAlertOk } from './alerts' + +export function fetchShows(url) { + return request( + 'SHOW_LIST_FETCH', + configureAxios().get(url), + [ + updateLastShowsFetchUrl(url), + ] + ) +} + +export function getShowDetails(imdbId) { + return request( + 'SHOW_GET_DETAILS', + configureAxios().post(`/shows/${imdbId}/refresh`) + ) +} + + +export function getEpisodeDetails(imdbId, season, episode) { + return request( + 'EPISODE_GET_DETAILS', + configureAxios().post(`/shows/${imdbId}/seasons/${season}/episodes/${episode}`), + ) +} + +export function updateEpisodeDetailsStore(imdbId, season, episode) { + return { + type: 'EPISODE_GET_DETAILS', + payload: { + imdbId, + season, + episode, + }, + } +} + +export function fetchShowDetails(imdbId) { + return request( + 'SHOW_FETCH_DETAILS', + configureAxios().get(`/shows/${imdbId}`) + ) +} + +export function addShowToWishlist(imdbId, season = null, episode = null) { + return request( + 'SHOW_ADD_TO_WISHLIST', + configureAxios().post(`/wishlist/shows/${imdbId}`, { + season: season, + episode: episode, + }), + [ + addAlertOk("Show added to the wishlist"), + updateShowWishlistStore(imdbId, true, season, episode), + ], + ) +} + +export function deleteShowFromWishlist(imdbId) { + return request( + 'SHOW_DELETE_FROM_WISHLIST', + configureAxios().delete(`/wishlist/shows/${imdbId}`), + [ + addAlertOk("Show deleted from the wishlist"), + updateShowWishlistStore(imdbId, false), + ], + ) +} + +export function updateShowWishlistStore(imdbId, wishlisted, season = null, episode = null) { + return { + type: 'SHOW_UPDATE_STORE_WISHLIST', + payload: { + wishlisted: wishlisted, + imdbId, + season, + episode, + } + } +} + +export function getShowExploreOptions() { + return request( + 'SHOW_GET_EXPLORE_OPTIONS', + configureAxios().get('/shows/explore/options') + ) +} + +export function selectShow(imdbId) { + return { + type: 'SELECT_SHOW', + imdbId + } +} + +export function updateLastShowsFetchUrl(url) { + return { + type: 'UPDATE_LAST_SHOWS_FETCH_URL', + payload: { + url: url, + }, + } +} diff --git a/src/public/js/actions/torrents.js b/src/public/js/actions/torrents.js new file mode 100644 index 0000000..e92880c --- /dev/null +++ b/src/public/js/actions/torrents.js @@ -0,0 +1,22 @@ +import { configureAxios, request } from '../requests' + +import { addAlertOk } from './alerts' + +export function addTorrent(url) { + return request( + 'ADD_TORRENT', + configureAxios().post('/torrents', { + url: url, + }), + [ + addAlertOk("Torrent added"), + ], + ) +} + +export function fetchTorrents() { + return request( + 'TORRENTS_FETCH', + configureAxios().get('/torrents') + ) +} diff --git a/src/public/js/actions/users.js b/src/public/js/actions/users.js new file mode 100644 index 0000000..76734e4 --- /dev/null +++ b/src/public/js/actions/users.js @@ -0,0 +1,46 @@ +import { configureAxios, request } from '../requests' + +import { addAlertOk } from './alerts' + +export function userLogout() { + return { + type: 'USER_LOGOUT', + } +} + +export function loginUser(username, password) { + return request( + 'USER_LOGIN', + configureAxios().post( + '/users/login', + { + username: username, + password: password, + }, + ), + ) +} + +export function updateUser(config) { + return request( + 'USER_UPDATE', + configureAxios().post('/users/edit', config), + [ + addAlertOk("User updated"), + ], + ) +} + +export function userSignUp(config) { + return request( + 'USER_SIGNUP', + configureAxios().post('/users/signup', config) + ) +} + +export function getUserInfos() { + return request( + 'GET_USER', + configureAxios().get('/users/details') + ) +} diff --git a/src/public/js/app.js b/src/public/js/app.js index 2948267..b7e7ac8 100644 --- a/src/public/js/app.js +++ b/src/public/js/app.js @@ -28,7 +28,7 @@ import { Router } from 'react-router' import { routerActions } from 'react-router-redux' // Action creators -import { dismissAlert } from './actions/actionCreators' +import { dismissAlert } from './actions/alerts' // Store import store, { history } from './store' @@ -41,9 +41,13 @@ import Alert from './components/alerts/alert' import getRoutes from './routes' function mapStateToProps(state) { + let torrentCount = 0; + if (state.torrentStore.has('torrents')) { + torrentCount = state.torrentStore.has('torrents').size; + } return { username: state.userStore.username, - torrentCount: state.torrentStore.get('torrents').size, + torrentCount: torrentCount, alerts: state.alerts, } } diff --git a/src/public/js/components/movies/list.js b/src/public/js/components/movies/list.js index 6609a88..91237c3 100644 --- a/src/public/js/components/movies/list.js +++ b/src/public/js/components/movies/list.js @@ -1,8 +1,9 @@ import React from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' -import { selectMovie, getMovieDetails, addTorrent, - addMovieToWishlist, deleteMovieFromWishlist } from '../../actions/actionCreators' +import { addTorrent } from '../../actions/torrents' +import { addMovieToWishlist, deleteMovieFromWishlist, + getMovieDetails, selectMovie } from '../../actions/movies' import DownloadButton from '../buttons/download' import TorrentsButton from './torrents' diff --git a/src/public/js/components/shows/details.js b/src/public/js/components/shows/details.js index e1faea5..bb39410 100644 --- a/src/public/js/components/shows/details.js +++ b/src/public/js/components/shows/details.js @@ -1,8 +1,9 @@ import React from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' -import { addTorrent, addShowToWishlist, deleteFromWishlist, - updateShowDetails, updateEpisodeDetailsStore, getEpisodeDetails } from '../../actions/actionCreators' +import { addTorrent } from '../../actions/torrents' +import { addShowToWishlist, deleteFromWishlist, getEpisodeDetails, + updateEpisodeDetailsStore, updateShowDetails } from '../../actions/shows' import Loader from '../loader/loader' import DownloadButton from '../buttons/download' diff --git a/src/public/js/components/shows/list.js b/src/public/js/components/shows/list.js index bca5c00..fb7452f 100644 --- a/src/public/js/components/shows/list.js +++ b/src/public/js/components/shows/list.js @@ -2,7 +2,7 @@ import React from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import { selectShow, addShowToWishlist, - deleteFromWishlist, getShowDetails } from '../../actions/actionCreators' + deleteFromWishlist, getShowDetails } from '../../actions/shows' import ListDetails from '../list/details' import ListPosters from '../list/posters' diff --git a/src/public/js/components/torrents/list.js b/src/public/js/components/torrents/list.js index 443fe9a..197c905 100644 --- a/src/public/js/components/torrents/list.js +++ b/src/public/js/components/torrents/list.js @@ -1,7 +1,7 @@ import React from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' -import { addTorrent } from '../../actions/actionCreators' +import { addTorrent } from '../../actions/torrents' function mapStateToProps(state) { return { torrents: state.torrentStore.get('torrents') }; diff --git a/src/public/js/components/users/edit.js b/src/public/js/components/users/edit.js index 4e28e8b..4b6af6a 100644 --- a/src/public/js/components/users/edit.js +++ b/src/public/js/components/users/edit.js @@ -1,18 +1,25 @@ import React from 'react' -import { Control, Form } from 'react-redux-form'; +import { connect } from 'react-redux' +import { bindActionCreators } from 'redux' -export default class UserEdit extends React.Component { - componentWillMount() { - this.props.getUserInfos(); - } +import { Control, Form } from 'react-redux-form'; +import { updateUser } from '../../actions/users' + +function mapStateToProps(state) { + return { user: state.userStore }; +} +const mapDispatchToProps = (dispatch) => + bindActionCreators({ updateUser }, dispatch) + +class UserEdit extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit() { this.props.updateUser({ - 'polochon_url': this.props.userStore.polochonUrl, - 'polochon_token': this.props.userStore.polochonToken, + 'polochon_url': this.props.user.polochonUrl, + 'polochon_token': this.props.user.polochonToken, 'password': this.refs.newPassword.value, 'password_confirm': this.refs.newPasswordConfirm.value, }); @@ -58,3 +65,4 @@ export default class UserEdit extends React.Component { ); } } +export default connect(mapStateToProps, mapDispatchToProps)(UserEdit); diff --git a/src/public/js/components/users/login.js b/src/public/js/components/users/login.js index 4b36812..be24d46 100644 --- a/src/public/js/components/users/login.js +++ b/src/public/js/components/users/login.js @@ -1,12 +1,22 @@ import React from 'react' +import { connect } from 'react-redux' +import { bindActionCreators } from 'redux' -export default class UserLoginForm extends React.Component { +import { loginUser } from '../../actions/users' + +function mapStateToProps(state) { + return { user: state.userStore }; +} +const mapDispatchToProps = (dispatch) => + bindActionCreators({ loginUser }, dispatch) + +class UserLoginForm extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); } componentWillReceiveProps(nextProps) { - if (!nextProps.userStore.isLogged) { + if (!nextProps.user.isLogged) { return } if (!nextProps.location.query.redirect) { @@ -19,7 +29,7 @@ export default class UserLoginForm extends React.Component { } handleSubmit(e) { e.preventDefault(); - if (this.props.userStore.userLoading) { + if (this.props.user.userLoading) { return; } const username = this.refs.username.value; @@ -47,12 +57,12 @@ export default class UserLoginForm extends React.Component {

- {this.props.userStore.userLoading && + {this.props.user.userLoading && } - {this.props.userStore.userLoading || + {this.props.user.userLoading || }
@@ -64,3 +74,4 @@ export default class UserLoginForm extends React.Component { ); } } +export default connect(mapStateToProps, mapDispatchToProps)(UserLoginForm); diff --git a/src/public/js/components/users/signup.js b/src/public/js/components/users/signup.js index 9a781a2..ad8b1c6 100644 --- a/src/public/js/components/users/signup.js +++ b/src/public/js/components/users/signup.js @@ -1,6 +1,13 @@ import React from 'react' +import { connect } from 'react-redux' +import { bindActionCreators } from 'redux' -export default class UserSignUp extends React.Component { +import { userSignUp } from '../../actions/users' + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ userSignUp }, dispatch) + +class UserSignUp extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); @@ -46,3 +53,4 @@ export default class UserSignUp extends React.Component { ); } } +export default connect(null, mapDispatchToProps)(UserSignUp); diff --git a/src/public/js/routes.js b/src/public/js/routes.js index d9f903a..9355f9a 100644 --- a/src/public/js/routes.js +++ b/src/public/js/routes.js @@ -8,7 +8,11 @@ import UserEdit from './components/users/edit' import UserSignUp from './components/users/signup' import TorrentList from './components/torrents/list' -import * as actionCreators from './actions/actionCreators' +import { fetchTorrents } from './actions/torrents' +import { userLogout, getUserInfos } from './actions/users' +import { fetchMovies, getMovieExploreOptions } from './actions/movies' +import { fetchShows, fetchShowDetails, getShowExploreOptions } from './actions/shows' + import store from './store' function startPollingTorrents() { @@ -56,7 +60,7 @@ const loginCheck = function(nextState, replace, next, f = null) { if (!pollingTorrentsId) { // Fetch the torrents every 10s pollingTorrentsId = setInterval(function() { - store.dispatch(actionCreators.fetchTorrents()); + store.dispatch(fetchTorrents()); }, 10000); } } @@ -90,7 +94,9 @@ export default function getRoutes(App) { path: '/users/edit', component: UserEdit, onEnter: function(nextState, replace, next) { - loginCheck(nextState, replace, next); + loginCheck(nextState, replace, next, function() { + store.dispatch(getUserInfos()); + }); }, }, { @@ -101,7 +107,7 @@ export default function getRoutes(App) { clearInterval(pollingTorrentsId); pollingTorrentsId = null; } - store.dispatch(actionCreators.userLogout()); + store.dispatch(userLogout()); replace('/users/login'); next(); }, @@ -111,7 +117,7 @@ export default function getRoutes(App) { component: MovieList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchMovies(`/movies/search/${nextState.params.search}`)); + store.dispatch(fetchMovies(`/movies/search/${nextState.params.search}`)); }); }, }, @@ -120,7 +126,7 @@ export default function getRoutes(App) { component: MovieList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchMovies('/movies/polochon')); + store.dispatch(fetchMovies('/movies/polochon')); }); }, }, @@ -132,9 +138,9 @@ export default function getRoutes(App) { var state = store.getState(); // Fetch the explore options if (Object.keys(state.movieStore.exploreOptions).length === 0) { - store.dispatch(actionCreators.getMovieExploreOptions()); + store.dispatch(getMovieExploreOptions()); } - store.dispatch(actionCreators.fetchMovies( + store.dispatch(fetchMovies( `/movies/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}` )); }); @@ -145,7 +151,7 @@ export default function getRoutes(App) { component: MovieList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchMovies('/wishlist/movies')); + store.dispatch(fetchMovies('/wishlist/movies')); }); }, }, @@ -154,7 +160,7 @@ export default function getRoutes(App) { component: ShowList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchShows(`/shows/search/${nextState.params.search}`)); + store.dispatch(fetchShows(`/shows/search/${nextState.params.search}`)); }); }, }, @@ -163,7 +169,7 @@ export default function getRoutes(App) { component: ShowList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchShows('/shows/polochon')); + store.dispatch(fetchShows('/shows/polochon')); }); }, }, @@ -172,7 +178,7 @@ export default function getRoutes(App) { component: ShowList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchShows('/wishlist/shows')); + store.dispatch(fetchShows('/wishlist/shows')); }); }, }, @@ -181,7 +187,7 @@ export default function getRoutes(App) { component: ShowDetails, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchShowDetails(nextState.params.imdbId)); + store.dispatch(fetchShowDetails(nextState.params.imdbId)); }); }, }, @@ -193,9 +199,9 @@ export default function getRoutes(App) { var state = store.getState(); // Fetch the explore options if (Object.keys(state.showStore.exploreOptions).length === 0) { - store.dispatch(actionCreators.getShowExploreOptions()); + store.dispatch(getShowExploreOptions()); } - store.dispatch(actionCreators.fetchShows( + store.dispatch(fetchShows( `/shows/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}` )); }); @@ -206,7 +212,7 @@ export default function getRoutes(App) { component: TorrentList, onEnter: function(nextState, replace, next) { loginCheck(nextState, replace, next, function() { - store.dispatch(actionCreators.fetchTorrents()); + store.dispatch(fetchTorrents()); }); }, },