1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00
Files
Radarr/frontend/src/Movie/Index/Select/MovieIndexPosterSelect.tsx
T
Bogdan abf3fc4557 Remove redundant code in selecting with click on poster
(cherry picked from commit b116f63a1d95a23a6f3684e6b60ead60c2584f0f)
2025-10-25 12:51:40 -05:00

53 lines
1.4 KiB
TypeScript

import React, { SyntheticEvent, useCallback } from 'react';
import { useSelect } from 'App/SelectContext';
import Icon from 'Components/Icon';
import Link from 'Components/Link/Link';
import { icons } from 'Helpers/Props';
import styles from './MovieIndexPosterSelect.css';
interface MovieIndexPosterSelectProps {
movieId: number;
titleSlug: string;
}
function MovieIndexPosterSelect({
movieId,
titleSlug,
}: MovieIndexPosterSelectProps) {
const [selectState, selectDispatch] = useSelect();
const isSelected = selectState.selectedState[movieId];
const onSelectPress = useCallback(
(event: SyntheticEvent<HTMLElement, PointerEvent>) => {
if (event.nativeEvent.ctrlKey || event.nativeEvent.metaKey) {
window.open(`${window.Radarr.urlBase}/movie/${titleSlug}`, '_blank');
return;
}
const shiftKey = event.nativeEvent.shiftKey;
selectDispatch({
type: 'toggleSelected',
id: movieId,
isSelected: !isSelected,
shiftKey,
});
},
[movieId, titleSlug, isSelected, selectDispatch]
);
return (
<Link className={styles.checkButton} onPress={onSelectPress}>
<span className={styles.checkContainer}>
<Icon
className={isSelected ? styles.selected : styles.unselected}
name={isSelected ? icons.CHECK_CIRCLE : icons.CIRCLE_OUTLINE}
size={20}
/>
</span>
</Link>
);
}
export default MovieIndexPosterSelect;