Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft for Episode List #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sldless
Copy link

@sldless sldless commented Oct 16, 2024

Summary by Sourcery

Add an EpisodeList component to display episodes for a series and integrate it into the video player controls with a toggle feature.

New Features:

  • Introduce an EpisodeList component to display a list of episodes for a given series.

Enhancements:

  • Add functionality to toggle the visibility of the EpisodeList in the video player controls.

Copy link

sourcery-ai bot commented Oct 16, 2024

Reviewer's Guide by Sourcery

This pull request implements a draft for an Episode List feature in a video player component. It adds functionality to display a list of episodes for a series and allows users to select and play individual episodes.

User Journey Diagram for Episode List Feature

journey
    title User Journey for Episode List Feature
    section Video Player
      User clicks on episode list icon: 5: User
      Episode list is displayed: 5: System
      User selects an episode: 5: User
      Episode details are shown in a modal: 5: System
      User clicks play episode: 5: User
      Episode starts playing: 5: System
Loading

Class Diagram for Episode List Feature

classDiagram
    class Controls {
        +bool EpisodeView
        +void toggleEpisodeView()
    }
    class EpisodeList {
        +string showId
        +BaseItemDto selectedEpisode
        +void handlePresentModalPress(BaseItemDto episode)
        +void closeModal()
        +void renderEpisode(BaseItemDto item)
    }
    Controls --> EpisodeList : uses
    EpisodeList --> EpisodeCard : uses
    EpisodeList --> Button : uses
    EpisodeList --> Text : uses
Loading

File-Level Changes

Change Details Files
Add Episode List toggle and view to video player controls
  • Import EpisodeCard component
  • Add state for EpisodeView
  • Implement toggleEpisodeView function
  • Add conditional rendering for Episode List button
  • Implement EpisodeView display with positioning
components/video-player/Controls.tsx
Create new EpisodeList component
  • Implement EpisodeList component with props and state
  • Add BottomSheetModal for episode details
  • Create styles for EpisodeList container
  • Implement episode selection and play functionality
components/EpisodeList.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sldless - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using responsive design techniques instead of hardcoded positioning for the episode list to ensure compatibility across different screen sizes.
  • The EpisodeList component is quite large. Consider breaking it down into smaller, more focused components to improve readability and maintainability.
  • There's commented-out code in the renderEpisode function. Either implement the EpisodeCard component or remove the commented code to keep the codebase clean.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +348 to +353
<View style={{
position: 'absolute',
top: 60,
left: 0,
right: 0,
}}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider using flexbox for more flexible layout

Using absolute positioning with hardcoded values might cause issues on different screen sizes or orientations. React Native's flexbox capabilities could provide a more robust solution.

Suggested change
<View style={{
position: 'absolute',
top: 60,
left: 0,
right: 0,
}}>
<View style={{
flex: 1,
marginTop: 60,
paddingHorizontal: 10,
}}>

Comment on lines +106 to +127
container: {
position: "absolute",
top: '50%',
left: '50%',
width: 550,
height: 205,
backgroundColor: '#171717',
transform: [{ translateX: -320 }, { translateY: 100 }],
marginTop: -100,
marginLeft: -250,
opacity: 0.65,
},
contentContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
separator: {
height: 3,
backgroundColor: '#CCCCCC',
marginVertical: 10,
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consolidate styles into StyleSheet

Moving all styles into the StyleSheet object would improve consistency and potentially performance. This includes styles currently defined inline in the JSX.

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    width: 550,
    height: 205,
    backgroundColor: 'rgba(23, 23, 23, 0.65)',
    transform: [{ translateX: -275 }, { translateY: 2.5 }],
  },
  contentContainer: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  separator: {
    height: 3,
    backgroundColor: '#CCCCCC',
    marginVertical: 10,
  },
});

Comment on lines +110 to +115
width: 550,
height: 205,
backgroundColor: '#171717',
transform: [{ translateX: -320 }, { translateY: 100 }],
marginTop: -100,
marginLeft: -250,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Use dynamic values for layout properties

Hardcoded values for width, height, and positioning may not work well across different device sizes. Consider using percentages, flex, or calculating these values based on screen dimensions.

Suggested change
width: 550,
height: 205,
backgroundColor: '#171717',
transform: [{ translateX: -320 }, { translateY: 100 }],
marginTop: -100,
marginLeft: -250,
width: '90%',
height: '30%',
backgroundColor: '#171717',
transform: [
{ translateX: '-50%' },
{ translateY: '-50%' }
],
marginTop: 0,
marginLeft: 0,

showId: string;
}

export const EpisodeList: React.FC<EpisodeListProps> = ({ showId }) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Implement error handling and loading state

There's currently no visible error state or loading indicator. This could lead to a poor user experience if the API call fails or takes a long time. Consider adding error handling and a loading state to improve robustness.

export const EpisodeList: React.FC<EpisodeListProps> = ({ showId }) => {
  const [api] = useAtom(apiAtom);
  const [isLoading, setIsLoading] = useState(true);
  const [error, setError] = useState<Error | null>(null);
  const [selectedEpisode, setSelectedEpisode] = useState<BaseItemDto | null>(null);

  useEffect(() => {
    fetchEpisodes();
  }, [showId]);

  const fetchEpisodes = async () => {

@@ -80,6 +82,9 @@ export const Controls: React.FC<Props> = ({
const [currentTime, setCurrentTime] = useState(0); // Seconds
const [remainingTime, setRemainingTime] = useState(0); // Seconds

const [EpisodeView, setEpisodeView] = useState(false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider extracting the episode list toggle functionality into a separate component.

While the addition of the episode list toggle provides quick access to episodes, it introduces unnecessary complexity to the Controls component. Consider extracting this functionality into a separate component to maintain a cleaner separation of concerns. Here's a suggested approach:

  1. Create a new EpisodeListToggle component:
const EpisodeListToggle = ({ item, onToggle, isVisible }) => {
  if (item?.Type !== "Episode") return null;

  return (
    <>
      <TouchableOpacity
        onPress={onToggle}
        className="aspect-square flex flex-col bg-neutral-800/90 rounded-xl items-center justify-center p-2"
      >
        <Ionicons name="list" size={24} color="white" />
      </TouchableOpacity>
      {isVisible && (
        <View style={{
          position: 'absolute',
          top: 60, 
          left: 0,
          right: 0,
        }}>
          <EpisodeList showId={item.SeriesId} />
        </View>
      )}
    </>
  );
};
  1. Update the Controls component to use the new EpisodeListToggle:
const Controls = ({ /* ...existing props */ }) => {
  const [episodeListVisible, setEpisodeListVisible] = useState(false);

  // ...existing code

  return (
    <View /* ...existing styles */>
      {/* ...existing code */}
      <View /* ...existing styles for top-right controls */>
        <EpisodeListToggle
          item={item}
          onToggle={() => setEpisodeListVisible(!episodeListVisible)}
          isVisible={episodeListVisible}
        />
        {/* ...other top-right controls */}
      </View>
      {/* ...rest of the component */}
    </View>
  );
};

This approach keeps the episode list functionality while simplifying the Controls component and improving maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant