mirror of
https://github.com/rishikanthc/Scriberr.git
synced 2026-06-28 06:46:25 +00:00
fix: resolve lint warnings in audio components
This commit is contained in:
committed by
Rishikanth Chandrasekaran
parent
7df90246d5
commit
4c0ce0f4e2
@@ -146,7 +146,7 @@ export const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({
|
||||
wavesurferRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [audioId, theme, getAuthHeaders]);
|
||||
}, [audioId, theme, getAuthHeaders]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Update height when collapsed state changes
|
||||
useEffect(() => {
|
||||
|
||||
@@ -69,6 +69,7 @@ export function AudioVisualizer({
|
||||
|
||||
const initAudio = () => {
|
||||
if (!contextRef.current) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const AudioContextClass = window.AudioContext || (window as any).webkitAudioContext;
|
||||
contextRef.current = new AudioContextClass();
|
||||
}
|
||||
@@ -89,7 +90,7 @@ export function AudioVisualizer({
|
||||
const source = audioSourceMap.get(audioEl)!;
|
||||
source.connect(analyzerRef.current!);
|
||||
analyzerRef.current!.connect(ctx.destination);
|
||||
} catch (e) { /* ignore already connected errors */ }
|
||||
} catch { /* ignore already connected errors */ }
|
||||
} else {
|
||||
try {
|
||||
const source = ctx.createMediaElementSource(audioEl);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useRef, useState, useEffect, forwardRef, useImperativeHandle } from "react";
|
||||
import { useRef, useState, useEffect, forwardRef, useImperativeHandle, useCallback } from "react";
|
||||
import { Play, Pause, AlertCircle } from "lucide-react";
|
||||
import { AudioVisualizer } from "./AudioVisualizer";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -79,13 +79,13 @@ export const EmberPlayer = forwardRef<EmberPlayerRef, EmberPlayerProps>(
|
||||
};
|
||||
|
||||
// --- 4. Advanced Scrubber Logic ---
|
||||
const calculateTimeFromEvent = (e: React.MouseEvent | MouseEvent) => {
|
||||
const calculateTimeFromEvent = useCallback((e: React.MouseEvent | MouseEvent) => {
|
||||
if (!progressRef.current || !duration) return 0;
|
||||
const rect = progressRef.current.getBoundingClientRect();
|
||||
let x = e.clientX - rect.left;
|
||||
x = Math.max(0, Math.min(x, rect.width));
|
||||
return (x / rect.width) * duration;
|
||||
};
|
||||
}, [duration]);
|
||||
|
||||
const handleScrubberMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
setIsDragging(true);
|
||||
@@ -119,7 +119,7 @@ export const EmberPlayer = forwardRef<EmberPlayerRef, EmberPlayerProps>(
|
||||
window.removeEventListener("mousemove", handleGlobalMouseMove);
|
||||
window.removeEventListener("mouseup", handleGlobalMouseUp);
|
||||
};
|
||||
}, [isDragging, duration]);
|
||||
}, [isDragging, calculateTimeFromEvent]);
|
||||
|
||||
const handleHoverMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!progressRef.current || !duration) return;
|
||||
@@ -271,5 +271,3 @@ export const EmberPlayer = forwardRef<EmberPlayerRef, EmberPlayerProps>(
|
||||
);
|
||||
|
||||
EmberPlayer.displayName = "EmberPlayer";
|
||||
|
||||
EmberPlayer.displayName = "EmberPlayer";
|
||||
Reference in New Issue
Block a user