import React, { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import cx from "classnames"; import * as GQL from "src/core/generated-graphql"; import { TextUtils } from "src/utils"; import { Button, Form, Spinner } from "react-bootstrap"; import { Icon } from "src/components/Shared"; import { useIntl } from "react-intl"; export interface IPlaylistViewer { scenes?: GQL.SlimSceneDataFragment[]; currentID?: string; start?: number; continue?: boolean; hasMoreScenes: boolean; setContinue: (v: boolean) => void; onSceneClicked: (id: string) => void; onNext: () => void; onPrevious: () => void; onRandom: () => void; onMoreScenes: () => void; onLessScenes: () => void; } export const QueueViewer: React.FC = ({ scenes, currentID, start, continue: continuePlaylist = false, hasMoreScenes, setContinue, onNext, onPrevious, onRandom, onSceneClicked, onMoreScenes, onLessScenes, }) => { const intl = useIntl(); const [lessLoading, setLessLoading] = useState(false); const [moreLoading, setMoreLoading] = useState(false); const currentIndex = scenes?.findIndex((s) => s.id === currentID); useEffect(() => { setLessLoading(false); setMoreLoading(false); }, [scenes]); function isCurrentScene(scene: GQL.SlimSceneDataFragment) { return scene.id === currentID; } function handleSceneClick( event: React.MouseEvent, id: string ) { onSceneClicked(id); event.preventDefault(); } function lessClicked() { setLessLoading(true); onLessScenes(); } function moreClicked() { setMoreLoading(true); onMoreScenes(); } function renderPlaylistEntry(scene: GQL.SlimSceneDataFragment) { return (
  • handleSceneClick(e, scene.id)} >
    {scene.title
    {scene.title ?? TextUtils.fileNameFromPath(scene.path)}
  • ); } return (
    { setContinue(!continuePlaylist); }} />
    {(currentIndex ?? 0) > 0 ? ( ) : ( "" )} {(currentIndex ?? 0) < (scenes ?? []).length - 1 ? ( ) : ( "" )}
    {(start ?? 0) > 1 ? (
    ) : undefined}
      {(scenes ?? []).map(renderPlaylistEntry)}
    {hasMoreScenes ? (
    ) : undefined}
    ); };