Add action when hitting enter on poster list page

This commit is contained in:
Lucas BEE 2018-08-18 18:38:42 +08:00
parent 1c19febf6f
commit 26b91c84b4
4 changed files with 21 additions and 0 deletions

View File

@ -10,6 +10,7 @@ export default function Poster(props) {
<img <img
src={props.data.get("poster_url")} src={props.data.get("poster_url")}
onClick={props.onClick} onClick={props.onClick}
onDoubleClick={props.onDoubleClick}
/> />
</a> </a>
</div> </div>

View File

@ -105,6 +105,8 @@ export default class ListPosters extends React.PureComponent {
loadMore={this.loadMore} loadMore={this.loadMore}
selectedImdbId={this.props.selectedImdbId} selectedImdbId={this.props.selectedImdbId}
selectPoster={this.props.onClick} selectPoster={this.props.onClick}
onDoubleClick={this.props.onDoubleClick}
onKeyEnter={this.props.onKeyEnter}
/> />
</div> </div>
); );
@ -129,6 +131,10 @@ class Posters extends React.PureComponent {
"j": 6, "j": 6,
}); });
if (event.key === "Enter") {
this.props.onKeyEnter(this.props.selectedImdbId);
}
if (! keyToDiff.has(event.key) ) { if (! keyToDiff.has(event.key) ) {
return; return;
} }
@ -199,6 +205,7 @@ class Posters extends React.PureComponent {
key={`poster-${imdbId}`} key={`poster-${imdbId}`}
selected={selected} selected={selected}
onClick={() => this.props.selectPoster(imdbId)} onClick={() => this.props.selectPoster(imdbId)}
onDoubleClick={() => this.props.onDoubleClick(imdbId)}
/> />
</div> </div>
) )

View File

@ -92,6 +92,8 @@ class MovieList extends React.PureComponent {
updateFilter={this.props.updateFilter} updateFilter={this.props.updateFilter}
filter={this.props.filter} filter={this.props.filter}
onClick={this.props.selectMovie} onClick={this.props.selectMovie}
onDoubleClick={function() { return; }}
onKeyEnter={function() { return; }}
params={this.props.params} params={this.props.params}
router={this.props.router} router={this.props.router}
loading={this.props.loading} loading={this.props.loading}

View File

@ -23,6 +23,15 @@ const mapDispatchToProps = (dispatch) =>
deleteShowFromWishlist, getShowDetails, updateFilter }, dispatch) deleteShowFromWishlist, getShowDetails, updateFilter }, dispatch)
class ShowList extends React.PureComponent { class ShowList extends React.PureComponent {
constructor(props) {
super(props);
this.showDetails = this.showDetails.bind(this);
}
showDetails(imdbId) {
return this.props.router.push("/shows/details/" + imdbId);
}
render() { render() {
let selectedShow; let selectedShow;
if (this.props.selectedImdbId !== "") { if (this.props.selectedImdbId !== "") {
@ -40,6 +49,8 @@ class ShowList extends React.PureComponent {
selectedImdbId={this.props.selectedImdbId} selectedImdbId={this.props.selectedImdbId}
filter={this.props.filter} filter={this.props.filter}
onClick={this.props.selectShow} onClick={this.props.selectShow}
onDoubleClick={this.showDetails}
onKeyEnter={this.showDetails}
router={this.props.router} router={this.props.router}
params={this.props.params} params={this.props.params}
loading={this.props.loading} loading={this.props.loading}