diff --git a/src/components/player/android/hooks/useDebounceCallback.ts b/src/components/player/android/hooks/useDebounceCallback.ts deleted file mode 100644 index 57762a7..0000000 --- a/src/components/player/android/hooks/useDebounceCallback.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { useCallback, useRef, useEffect } from 'react'; - -export function useDebounceCallback void>( - callback: T, - delay: number -) { - const timeoutRef = useRef | null>(null); - const callbackRef = useRef(callback); - - // Sync latest callback to avoid stale closures - useEffect(() => { - callbackRef.current = callback; - }, [callback]); - - const debouncedFunction = useCallback( - (...args: Parameters) => { - if (timeoutRef.current) clearTimeout(timeoutRef.current); - timeoutRef.current = setTimeout(() => { - callbackRef.current(...args); - }, delay); - }, - [delay] - ); - - // Cleanup on unmount to prevent memory leaks - useEffect(() => { - return () => { - if (timeoutRef.current) clearTimeout(timeoutRef.current); - }; - }, []); - - return debouncedFunction; -} diff --git a/src/components/player/controls/PlayerControls.tsx b/src/components/player/controls/PlayerControls.tsx index b558cd4..444666c 100644 --- a/src/components/player/controls/PlayerControls.tsx +++ b/src/components/player/controls/PlayerControls.tsx @@ -7,7 +7,6 @@ import Slider from '@react-native-community/slider'; import { styles } from '../utils/playerStyles'; // Updated styles import { getTrackDisplayName } from '../utils/playerUtils'; import { useTheme } from '../../../contexts/ThemeContext'; -import { useDebounceCallback } from '../android/hooks/useDebounceCallback'; interface PlayerControlsProps { showControls: boolean; @@ -135,15 +134,6 @@ export const PlayerControls: React.FC = ({ const playIconOpacity = React.useRef(new Animated.Value(1)).current; /* Handle Seek with Animation */ - const [skipRewindSeconds, setSkipRewindSeconds] = React.useState(0); - const finalSkipRewind = (finalValue: number) => { - console.log(`Final value processed: ${finalValue}`); - skip(finalValue); - setSkipRewindSeconds(0); - } - const debouncedSkip = useDebounceCallback((val: number) => { - finalSkipRewind(val); - }, 800); const handleSeekWithAnimation = (seconds: number) => { const isForward = seconds > 0; @@ -222,11 +212,7 @@ export const PlayerControls: React.FC = ({ arcRotation.setValue(0); }); - setSkipRewindSeconds(prev => { - const nextVal = prev + seconds; - debouncedSkip(nextVal); - return nextVal; - }); + skip(seconds); }; /* Handle Play/Pause with Animation */