mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
Added reference documentation for: src/routes/Player/SideDrawer/SideDrawer.tsx
This commit is contained in:
parent
cf73c7942d
commit
ea1825eaee
1 changed files with 26 additions and 0 deletions
|
|
@ -9,6 +9,9 @@ import { MetaPreview, Video } from 'stremio/components';
|
|||
import SeasonsBar from 'stremio/routes/MetaDetails/VideosList/SeasonsBar';
|
||||
import styles from './SideDrawer.less';
|
||||
|
||||
/**
|
||||
* Props for the SideDrawer component
|
||||
*/
|
||||
type Props = {
|
||||
className?: string;
|
||||
seriesInfo: SeriesInfo;
|
||||
|
|
@ -18,6 +21,11 @@ type Props = {
|
|||
transitionEnded: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* A side drawer component that displays metadata and video list for a series.
|
||||
* Filters videos by season and provides controls for marking videos as watched.
|
||||
* Automatically scrolls to the selected video after transition completes.
|
||||
*/
|
||||
const SideDrawer = memo(forwardRef<HTMLDivElement, Props>(({ seriesInfo, className, closeSideDrawer, selected, ...props }: Props, ref) => {
|
||||
const { core } = useServices();
|
||||
const [season, setSeason] = useState<number>(seriesInfo?.season);
|
||||
|
|
@ -46,6 +54,9 @@ const SideDrawer = memo(forwardRef<HTMLDivElement, Props>(({ seriesInfo, classNa
|
|||
.sort((a, b) => (a || Number.MAX_SAFE_INTEGER) - (b || Number.MAX_SAFE_INTEGER));
|
||||
}, [props.metaItem.videos]);
|
||||
|
||||
/**
|
||||
* Updates the selected season when a new season is chosen from the seasons bar
|
||||
*/
|
||||
const seasonOnSelect = useCallback((event: { value: string }) => {
|
||||
setSeason(parseInt(event.value));
|
||||
}, []);
|
||||
|
|
@ -54,6 +65,9 @@ const SideDrawer = memo(forwardRef<HTMLDivElement, Props>(({ seriesInfo, classNa
|
|||
return videos.every((video) => video.watched);
|
||||
}, [videos]);
|
||||
|
||||
/**
|
||||
* Dispatches an action to toggle the watched status of a video
|
||||
*/
|
||||
const onMarkVideoAsWatched = useCallback((video: Video, watched: boolean) => {
|
||||
core.transport.dispatch({
|
||||
action: 'Player',
|
||||
|
|
@ -64,6 +78,11 @@ const SideDrawer = memo(forwardRef<HTMLDivElement, Props>(({ seriesInfo, classNa
|
|||
});
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Dispatches an action to toggle the watched status of all videos in a season
|
||||
* @param season - The season number to mark
|
||||
* @param watched - Current watched status to toggle
|
||||
*/
|
||||
const onMarkSeasonAsWatched = (season: number, watched: boolean) => {
|
||||
core.transport.dispatch({
|
||||
action: 'Player',
|
||||
|
|
@ -74,10 +93,17 @@ const SideDrawer = memo(forwardRef<HTMLDivElement, Props>(({ seriesInfo, classNa
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Prevents event propagation to avoid closing the drawer when clicking inside it
|
||||
* @param event - The mouse event to stop
|
||||
*/
|
||||
const onMouseDown = (event: React.MouseEvent) => {
|
||||
event.stopPropagation();
|
||||
};
|
||||
|
||||
/**
|
||||
* Scrolls the selected video into view after the drawer transition completes
|
||||
*/
|
||||
const onTransitionEnd = () => {
|
||||
selectedVideoRef.current?.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
|
|
|
|||
Loading…
Reference in a new issue