[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:
mathysPaul
2024-01-07 01:30:58 +01:00
committed by Clément Le Bihan
parent a103666caf
commit 5ef3885f72
4 changed files with 5 additions and 7 deletions
+2 -2
View File
@@ -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.