[FIX] MusicList, MusicItem, IconButton: Prevent double-add on consecutive likes
Fixes the issue where consecutive likes on a track mistakenly added it twice to the liked list. Now ensures correct toggling between like and unlike.
This commit is contained in:
committed by
Clément Le Bihan
parent
a103666caf
commit
5ef3885f72
@@ -30,7 +30,7 @@ type IconButtonProps = {
|
||||
/**
|
||||
* Callback function triggered when the button is pressed.
|
||||
*/
|
||||
onPress?: () => void | Promise<void>;
|
||||
onPress?: (state: boolean) => void | Promise<void>;
|
||||
|
||||
/**
|
||||
* Size of the icon.
|
||||
@@ -183,7 +183,7 @@ const IconButton: React.FC<IconButtonProps> = ({
|
||||
const toggleState = async () => {
|
||||
// Execute onPress if provided.
|
||||
if (onPress) {
|
||||
await onPress();
|
||||
await onPress(!isActiveState);
|
||||
}
|
||||
|
||||
// Toggle isActiveState.
|
||||
|
||||
Reference in New Issue
Block a user