diff --git a/front/components/UI/IconButton.tsx b/front/components/UI/IconButton.tsx index a2c9d02..a012ac8 100644 --- a/front/components/UI/IconButton.tsx +++ b/front/components/UI/IconButton.tsx @@ -30,7 +30,7 @@ type IconButtonProps = { /** * Callback function triggered when the button is pressed. */ - onPress?: () => void | Promise; + onPress?: (state: boolean) => void | Promise; /** * Size of the icon. @@ -183,7 +183,7 @@ const IconButton: React.FC = ({ const toggleState = async () => { // Execute onPress if provided. if (onPress) { - await onPress(); + await onPress(!isActiveState); } // Toggle isActiveState. diff --git a/front/components/UI/MusicItem.tsx b/front/components/UI/MusicItem.tsx index 804f50a..8d12953 100644 --- a/front/components/UI/MusicItem.tsx +++ b/front/components/UI/MusicItem.tsx @@ -33,7 +33,7 @@ export interface MusicItemType { style?: ViewStyle | ViewStyle[]; /** Callback function triggered when the like button is pressed. */ - onLike: () => void; + onLike: (state: boolean) => void; /** Callback function triggered when the song is played. */ onPlay: () => void; diff --git a/front/components/UI/MusicList.tsx b/front/components/UI/MusicList.tsx index 6af7f01..4272ccd 100644 --- a/front/components/UI/MusicList.tsx +++ b/front/components/UI/MusicList.tsx @@ -237,8 +237,6 @@ const styles = StyleSheet.create({ // Using `memo` to optimize rendering performance by memorizing the component's output. // This ensures that the component only re-renders when its props change. const MusicList = memo(MusicListComponent, (prev, next) => { - console.log('AAAAA'); - console.log(prev.initialMusics, next.initialMusics); return prev.initialMusics.length == next.initialMusics.length; }); diff --git a/front/views/MusicView.tsx b/front/views/MusicView.tsx index 4af18f6..aeef2a0 100644 --- a/front/views/MusicView.tsx +++ b/front/views/MusicView.tsx @@ -43,8 +43,8 @@ const MusicListCC = ({ data, isLoading, refetch }: MusicListCCProps) => { lastScore: song.lastScore, bestScore: song.bestScore, liked: isLiked, - onLike: () => { - mutateAsync({ songId: song.id, like: !isLiked }).then(() => refetch()); + onLike: (state: boolean) => { + mutateAsync({ songId: song.id, like: state }).then(() => refetch()); }, onPlay: () => navigation.navigate('Play', { songId: song.id }), };