mirror of
https://github.com/Radarr/Radarr.git
synced 2026-03-05 13:21:25 -05:00
New: Select with poster click in movie selection (#11187)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { SyntheticEvent, useCallback, useState } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { useSelect } from 'App/SelectContext';
|
||||||
import { MOVIE_SEARCH, REFRESH_MOVIE } from 'Commands/commandNames';
|
import { MOVIE_SEARCH, REFRESH_MOVIE } from 'Commands/commandNames';
|
||||||
import Icon from 'Components/Icon';
|
import Icon from 'Components/Icon';
|
||||||
import ImdbRating from 'Components/ImdbRating';
|
import ImdbRating from 'Components/ImdbRating';
|
||||||
@@ -141,8 +142,31 @@ function MovieIndexPoster(props: MovieIndexPosterProps) {
|
|||||||
setIsDeleteMovieModalOpen(false);
|
setIsDeleteMovieModalOpen(false);
|
||||||
}, [setIsDeleteMovieModalOpen]);
|
}, [setIsDeleteMovieModalOpen]);
|
||||||
|
|
||||||
|
const [selectState, selectDispatch] = useSelect();
|
||||||
|
|
||||||
|
const onSelectPress = useCallback(
|
||||||
|
(event: SyntheticEvent<HTMLElement, MouseEvent>) => {
|
||||||
|
if (event.nativeEvent.ctrlKey || event.nativeEvent.metaKey) {
|
||||||
|
window.open(`/movie/${tmdbId}`, '_blank');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const shiftKey = event.nativeEvent.shiftKey;
|
||||||
|
|
||||||
|
selectDispatch({
|
||||||
|
type: 'toggleSelected',
|
||||||
|
id: movieId,
|
||||||
|
isSelected: !selectState.selectedState[movieId],
|
||||||
|
shiftKey,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[movieId, selectState.selectedState, selectDispatch, tmdbId]
|
||||||
|
);
|
||||||
|
|
||||||
const link = `/movie/${tmdbId}`;
|
const link = `/movie/${tmdbId}`;
|
||||||
|
|
||||||
|
const linkProps = isSelectMode ? { onPress: onSelectPress } : { to: link };
|
||||||
|
|
||||||
const elementStyle = {
|
const elementStyle = {
|
||||||
width: `${posterWidth}px`,
|
width: `${posterWidth}px`,
|
||||||
height: `${posterHeight}px`,
|
height: `${posterHeight}px`,
|
||||||
@@ -196,7 +220,7 @@ function MovieIndexPoster(props: MovieIndexPosterProps) {
|
|||||||
<div className={styles.deleted} title={translate('Deleted')} />
|
<div className={styles.deleted} title={translate('Deleted')} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Link className={styles.link} style={elementStyle} to={link}>
|
<Link className={styles.link} style={elementStyle} {...linkProps}>
|
||||||
<MoviePoster
|
<MoviePoster
|
||||||
style={elementStyle}
|
style={elementStyle}
|
||||||
images={images}
|
images={images}
|
||||||
|
|||||||
Reference in New Issue
Block a user