refactor: pause video when click on logs

This commit is contained in:
2026-06-18 11:41:25 +05:30
parent c6894bfea0
commit defb956751
2 changed files with 23 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
'use client';
import { useEffect, useRef } from 'react';
import { Activity, Film, MapPin } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { ScrollArea } from '@/components/ui/scroll-area';
@@ -21,6 +22,15 @@ const formatVideoTime = (seconds: number) => {
};
const DetectionLogs = ({ logs, activeLogId, onSeek }: DetectionLogsProps) => {
const activeLogRef = useRef<HTMLButtonElement | null>(null);
useEffect(() => {
activeLogRef.current?.scrollIntoView({
block: 'nearest',
behavior: 'smooth',
});
}, [activeLogId]);
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
@@ -50,6 +60,7 @@ const DetectionLogs = ({ logs, activeLogId, onSeek }: DetectionLogsProps) => {
return (
<button
key={`${log.id}-${log.frame}`}
ref={isActive ? activeLogRef : null}
type="button"
onClick={() => onSeek(log)}
className={cn(