From 614d1ab11e95dae4d556371d31ee4b9ecbf74c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Sat, 20 May 2017 00:08:07 +0200 Subject: [PATCH] Keep the last shows fetched URL --- src/public/js/actions/actionCreators.js | 28 ++++++++++++------------- src/public/js/app.js | 8 +++++-- src/public/js/reducers/shows.js | 5 +++++ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/public/js/actions/actionCreators.js b/src/public/js/actions/actionCreators.js index 1c07542..dc51d9b 100644 --- a/src/public/js/actions/actionCreators.js +++ b/src/public/js/actions/actionCreators.js @@ -175,14 +175,10 @@ export function fetchMovies(url) { export function fetchShows(url) { return request( 'SHOW_LIST_FETCH', - configureAxios().get(url) - ) -} - -export function searchShows(search) { - return request( - 'SEARCH_SHOWS', - configureAxios().post('/shows/search', search) + configureAxios().get(url), + [ + updateLastShowsFetchUrl(url), + ] ) } @@ -256,13 +252,6 @@ export function updateShowWishlistStore(imdbId, wishlisted, season = null, episo } } -export function exploreShows(source, category) { - return request( - 'EXPLORE_SHOWS', - configureAxios().get(`/shows/explore?source=${encodeURI(source)}&category=${encodeURI(category)}`) - ) -} - export function getShowExploreOptions() { return request( 'SHOW_GET_EXPLORE_OPTIONS', @@ -277,6 +266,15 @@ export function selectShow(imdbId) { } } +export function updateLastShowsFetchUrl(url) { + return { + type: 'UPDATE_LAST_SHOWS_FETCH_URL', + payload: { + url: url, + }, + } +} + // ====================== // AddTorrent // ====================== diff --git a/src/public/js/app.js b/src/public/js/app.js index c97a80e..2583361 100644 --- a/src/public/js/app.js +++ b/src/public/js/app.js @@ -133,7 +133,9 @@ const routes = { if (Object.keys(state.movieStore.exploreOptions).length === 0) { store.dispatch(actionCreators.getMovieExploreOptions()); } - store.dispatch(actionCreators.fetchMovies(`/movies/explore?source=${nextState.params.source}&category=${nextState.params.category}`)); + store.dispatch(actionCreators.fetchMovies( + `/movies/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}` + )); }); }, }, @@ -192,7 +194,9 @@ const routes = { if (Object.keys(state.showStore.exploreOptions).length === 0) { store.dispatch(actionCreators.getShowExploreOptions()); } - store.dispatch(actionCreators.fetchShows(`/shows/explore?source=${nextState.params.source}&category=${nextState.params.category}`)); + store.dispatch(actionCreators.fetchShows( + `/shows/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}` + )); }); }, }, diff --git a/src/public/js/reducers/shows.js b/src/public/js/reducers/shows.js index ea76dbd..4bf5ab1 100644 --- a/src/public/js/reducers/shows.js +++ b/src/public/js/reducers/shows.js @@ -9,6 +9,7 @@ const defaultState = { }, search: "", getDetails: false, + lastShowsFetchUrl: "", exploreOptions: {}, }; @@ -73,6 +74,10 @@ export default function showStore(state = defaultState, action) { shows: updateShowsStoreWishlist(state.shows.slice(), action.payload), show: updateShowStoreWishlist(Object.assign({}, state.show), action.payload), }) + case 'UPDATE_LAST_SHOWS_FETCH_URL': + return Object.assign({}, state, { + lastShowsFetchUrl: action.payload.url, + }) case 'SELECT_SHOW': // Don't select the show if we're fetching another show's details if (state.fetchingDetails) {