Add button to refresh the show details
This commit is contained in:
parent
eb7f5c88bf
commit
dcde20f170
@ -181,6 +181,13 @@ export function searchShows(search) {
|
||||
)
|
||||
}
|
||||
|
||||
export function getShowDetails(imdbId) {
|
||||
return request(
|
||||
'SHOW_GET_DETAILS',
|
||||
configureAxios().post(`/shows/${imdbId}/refresh`)
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchShowDetails(imdbId) {
|
||||
return request(
|
||||
'SHOW_FETCH_DETAILS',
|
||||
|
@ -58,6 +58,8 @@ export default class ShowList extends React.Component {
|
||||
show={selectedShow}
|
||||
deleteFromWishlist={this.props.deleteShowFromWishlist}
|
||||
addToWishlist={this.props.addShowToWishlist}
|
||||
getDetails={this.props.getShowDetails}
|
||||
fetching={this.props.showStore.getDetails}
|
||||
/>
|
||||
</ListDetails>
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import React from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { DropdownButton } from 'react-bootstrap'
|
||||
|
||||
import { WishlistButton } from '../buttons/actions'
|
||||
import { WishlistButton, RefreshButton } from '../buttons/actions'
|
||||
|
||||
export default function ShowButtons(props) {
|
||||
const imdbLink = `http://www.imdb.com/title/${props.show.imdb_id}`;
|
||||
@ -13,6 +13,8 @@ export default function ShowButtons(props) {
|
||||
show={props.show}
|
||||
addToWishlist={props.addToWishlist}
|
||||
deleteFromWishlist={props.deleteFromWishlist}
|
||||
getDetails={props.getDetails}
|
||||
fetching={props.fetching}
|
||||
/>
|
||||
<a type="button" className="btn btn-warning btn-sm" href={imdbLink}>
|
||||
<i className="fa fa-external-link"></i> IMDB
|
||||
@ -28,6 +30,11 @@ function ActionsButton(props) {
|
||||
let wishlisted = (props.show.tracked_season !== null && props.show.tracked_episode !== null);
|
||||
return (
|
||||
<DropdownButton className="btn btn-default btn-sm" title="Actions" id="actions-button" dropup>
|
||||
<RefreshButton
|
||||
fetching={props.fetching}
|
||||
resourceId={props.show.imdb_id}
|
||||
getDetails={props.getDetails}
|
||||
/>
|
||||
<WishlistButton
|
||||
resourceId={props.show.imdb_id}
|
||||
wishlisted={wishlisted}
|
||||
|
@ -8,6 +8,7 @@ const defaultState = {
|
||||
seasons: [],
|
||||
},
|
||||
search: "",
|
||||
getDetails: false,
|
||||
};
|
||||
|
||||
export default function showStore(state = defaultState, action) {
|
||||
@ -27,6 +28,15 @@ export default function showStore(state = defaultState, action) {
|
||||
selectedImdbId: selectedImdbId,
|
||||
loading: false,
|
||||
})
|
||||
case 'SHOW_GET_DETAILS_PENDING':
|
||||
return Object.assign({}, state, {
|
||||
getDetails: true,
|
||||
})
|
||||
case 'SHOW_GET_DETAILS_FULFILLED':
|
||||
return Object.assign({}, state, {
|
||||
shows: updateShowDetails(state.shows.slice(), action.payload.data),
|
||||
getDetails: false,
|
||||
})
|
||||
case 'SHOW_FETCH_DETAILS_PENDING':
|
||||
return Object.assign({}, state, {
|
||||
loading: true,
|
||||
@ -149,3 +159,9 @@ function updateShowStoreWishlist(show, payload) {
|
||||
show.tracked_episode = episode;
|
||||
return show
|
||||
}
|
||||
|
||||
function updateShowDetails(shows, data) {
|
||||
let index = shows.map((el) => el.imdb_id).indexOf(data.imdb_id);
|
||||
shows[index] = data;
|
||||
return shows
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user