Keep the last movie fetched URL
This commit is contained in:
parent
fcf64fb4ee
commit
38a17d526d
@ -85,6 +85,15 @@ export function getUserInfos() {
|
||||
// Movies
|
||||
// ======================
|
||||
|
||||
export function updateLastMovieFetchUrl(url) {
|
||||
return {
|
||||
type: 'UPDATE_LAST_MOVIE_FETCH_URL',
|
||||
payload: {
|
||||
url: url,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function selectMovie(imdbId) {
|
||||
return {
|
||||
type: 'SELECT_MOVIE',
|
||||
@ -113,13 +122,6 @@ export function searchMovies(search) {
|
||||
)
|
||||
}
|
||||
|
||||
export function exploreMovies(source, category) {
|
||||
return request(
|
||||
'EXPLORE_MOVIES',
|
||||
configureAxios().get(`/movies/explore?source=${encodeURI(source)}&category=${encodeURI(category)}`)
|
||||
)
|
||||
}
|
||||
|
||||
export function getMovieDetails(imdbId) {
|
||||
return request(
|
||||
'MOVIE_GET_DETAILS',
|
||||
@ -173,10 +175,18 @@ export function updateMovieWishlistStore(imdbId, wishlisted) {
|
||||
export function fetchMovies(url) {
|
||||
return request(
|
||||
'MOVIE_LIST_FETCH',
|
||||
configureAxios().get(url)
|
||||
configureAxios().get(url),
|
||||
[
|
||||
updateLastMovieFetchUrl(url),
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
export function exploreMovies(source, category) {
|
||||
const url = `/movies/explore?source=${encodeURI(source)}&category=${encodeURI(category)}`;
|
||||
return fetchMovies(url);
|
||||
}
|
||||
|
||||
// ======================
|
||||
// Shows
|
||||
// ======================
|
||||
|
@ -5,6 +5,7 @@ const defaultState = {
|
||||
perPage: 30,
|
||||
selectedImdbId: "",
|
||||
fetchingDetails: false,
|
||||
lastFetchUrl: "",
|
||||
exploreOptions: {},
|
||||
search: "",
|
||||
};
|
||||
@ -28,15 +29,6 @@ export default function movieStore(state = defaultState, action) {
|
||||
selectedImdbId: selectedImdbId,
|
||||
loading: false,
|
||||
})
|
||||
case 'EXPLORE_MOVIES_PENDING':
|
||||
return Object.assign({}, state, {
|
||||
loading: true,
|
||||
})
|
||||
case 'EXPLORE_MOVIES_FULFILLED':
|
||||
return Object.assign({}, state, {
|
||||
movies: action.payload.data,
|
||||
loading: false,
|
||||
})
|
||||
case 'SEARCH_MOVIES_PENDING':
|
||||
return Object.assign({}, state, {
|
||||
loading: true,
|
||||
@ -63,6 +55,10 @@ export default function movieStore(state = defaultState, action) {
|
||||
return Object.assign({}, state, {
|
||||
exploreOptions: action.payload.data,
|
||||
})
|
||||
case 'UPDATE_LAST_MOVIE_FETCH_URL':
|
||||
return Object.assign({}, state, {
|
||||
lastFetchUrl: action.payload.url,
|
||||
})
|
||||
case 'DELETE_MOVIE':
|
||||
return Object.assign({}, state, {
|
||||
movies: state.movies.filter((e) => (e.imdb_id !== action.imdbId)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user