fix(artplayer-wrapper): allow toggling rating by clicking the same star
- Modify handleStarClick to cancel rating when clicking the current rating again - Update local average rating based on toggle logic - Add localAvgRating as dependency to useCallback hook to keep updated state
This commit is contained in:
parent
dd08765ab9
commit
8f652fdf08
BIN
data/media.db
BIN
data/media.db
Binary file not shown.
|
|
@ -402,10 +402,13 @@ export default function ArtPlayerWrapper({
|
|||
// Handle individual star click for rating
|
||||
const handleStarClick = useCallback((rating: number) => {
|
||||
if (onRate) {
|
||||
onRate(video.id, rating);
|
||||
setLocalAvgRating(rating);
|
||||
const currentRating = Math.round(localAvgRating);
|
||||
// If clicking the same star as current rating, cancel the rating
|
||||
const newRating = currentRating === rating ? 0 : rating;
|
||||
onRate(video.id, newRating);
|
||||
setLocalAvgRating(newRating);
|
||||
}
|
||||
}, [onRate, video.id]);
|
||||
}, [onRate, video.id, localAvgRating]);
|
||||
|
||||
// Format time display
|
||||
const formatTime = (time: number) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue