-
Notifications
You must be signed in to change notification settings - Fork 32
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
base: master
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis 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 Featurejourney
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
Class Diagram for Episode List FeatureclassDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
<View style={{ | ||
position: 'absolute', | ||
top: 60, | ||
left: 0, | ||
right: 0, | ||
}}> |
There was a problem hiding this comment.
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.
<View style={{ | |
position: 'absolute', | |
top: 60, | |
left: 0, | |
right: 0, | |
}}> | |
<View style={{ | |
flex: 1, | |
marginTop: 60, | |
paddingHorizontal: 10, | |
}}> |
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, | ||
} |
There was a problem hiding this comment.
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,
},
});
width: 550, | ||
height: 205, | ||
backgroundColor: '#171717', | ||
transform: [{ translateX: -320 }, { translateY: 100 }], | ||
marginTop: -100, | ||
marginLeft: -250, |
There was a problem hiding this comment.
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.
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 }) => { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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:
- 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>
)}
</>
);
};
- 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.
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:
Enhancements: