Re-fetch the last fetched URL after deleting a movie
This keeps the store consistent with the backend
This commit is contained in:
parent
c1bd0bd3bc
commit
fce19bf3d8
@ -115,18 +115,15 @@ export function getMovieDetails(imdbId) {
|
||||
)
|
||||
}
|
||||
|
||||
export function deleteMovie(imdbId) {
|
||||
return {
|
||||
type: 'MOVIE_DELETE',
|
||||
imdbId
|
||||
}
|
||||
// return request(
|
||||
// 'MOVIE_DELETE',
|
||||
// configureAxios().delete(`/movies/${imdbId}`),
|
||||
// [
|
||||
// addAlertOk("Movie deleted"),
|
||||
// ],
|
||||
// )
|
||||
export function deleteMovie(imdbId, lastFetchUrl) {
|
||||
return request(
|
||||
'MOVIE_DELETE',
|
||||
configureAxios().delete(`/movies/${imdbId}`),
|
||||
[
|
||||
fetchMovies(lastFetchUrl),
|
||||
addAlertOk("Movie deleted"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
export function addMovieToWishlist(imdbId) {
|
||||
|
@ -43,8 +43,7 @@ export class DeleteButton extends React.Component {
|
||||
}
|
||||
handleClick(e) {
|
||||
e.preventDefault();
|
||||
this.props.deleteFunc(this.props.resourceId);
|
||||
this.props.fetchFunc();
|
||||
this.props.deleteFunc(this.props.resourceId, this.props.lastFetchUrl);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
|
@ -93,9 +93,7 @@ export default class ListPosters extends React.Component {
|
||||
display={!displayFilter}
|
||||
params={this.props.params}
|
||||
router={this.props.router}
|
||||
fetchOptions={this.props.fetchExploreOptions}
|
||||
options={this.props.exploreOptions}
|
||||
explore={this.props.explore}
|
||||
/>
|
||||
<Posters
|
||||
elmts={elmts}
|
||||
|
@ -14,8 +14,8 @@ export default function ActionsButton(props) {
|
||||
{props.hasMovie &&
|
||||
<DeleteButton
|
||||
resourceId={props.movieId}
|
||||
lastFetchUrl={props.lastFetchUrl}
|
||||
deleteFunc={props.deleteMovie}
|
||||
fetchFunc={() => props.fetchMovies(props.lastFetchUrl)}
|
||||
isUserAdmin={props.isUserAdmin}
|
||||
/>
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ export default class MovieList extends React.Component {
|
||||
addToWishlist={this.props.addMovieToWishlist}
|
||||
deleteFromWishlist={this.props.deleteMovieFromWishlist}
|
||||
fetchMovies={this.props.fetchMovies}
|
||||
lastFetchUrl={this.props.lastFetchUrl}
|
||||
lastFetchUrl={this.props.movieStore.lastFetchUrl}
|
||||
/>
|
||||
</ListDetails>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user