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