mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-13 02:27:38 +03:00
fix activity stream group from being highlighted prematurely
This commit is contained in:
parent
950d8e74f5
commit
f673398053
@ -321,6 +321,7 @@ export default function HlsVideoPlayer({
|
|||||||
videoDimensions.height > 0 && (
|
videoDimensions.height > 0 && (
|
||||||
<div className="absolute z-50 size-full">
|
<div className="absolute z-50 size-full">
|
||||||
<ObjectTrackOverlay
|
<ObjectTrackOverlay
|
||||||
|
key={`${selectedObjectId}-${currentTime}`}
|
||||||
camera={camera}
|
camera={camera}
|
||||||
selectedObjectId={selectedObjectId}
|
selectedObjectId={selectedObjectId}
|
||||||
currentTime={currentTime}
|
currentTime={currentTime}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export default function ActivityStream({
|
|||||||
const { selectedObjectId } = useActivityStream();
|
const { selectedObjectId } = useActivityStream();
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
// Group activities by timestamp (within 1 second resolution window)
|
// group activities by timestamp (within 1 second resolution window)
|
||||||
const groupedActivities = useMemo(() => {
|
const groupedActivities = useMemo(() => {
|
||||||
const groups: { [key: number]: ObjectLifecycleSequence[] } = {};
|
const groups: { [key: number]: ObjectLifecycleSequence[] } = {};
|
||||||
|
|
||||||
@ -31,10 +31,15 @@ export default function ActivityStream({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return Object.entries(groups)
|
return Object.entries(groups)
|
||||||
.map(([timestamp, activities]) => ({
|
.map(([_timestamp, activities]) => {
|
||||||
timestamp: parseInt(timestamp),
|
const sortedActivities = activities.sort(
|
||||||
activities: activities.sort((a, b) => a.timestamp - b.timestamp),
|
(a, b) => a.timestamp - b.timestamp,
|
||||||
}))
|
);
|
||||||
|
return {
|
||||||
|
timestamp: sortedActivities[0].timestamp, // use the earliest activity timestamp
|
||||||
|
activities: sortedActivities,
|
||||||
|
};
|
||||||
|
})
|
||||||
.sort((a, b) => a.timestamp - b.timestamp);
|
.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
}, [timelineData]);
|
}, [timelineData]);
|
||||||
|
|
||||||
@ -57,9 +62,14 @@ export default function ActivityStream({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!scrollRef.current) return;
|
if (!scrollRef.current) return;
|
||||||
|
|
||||||
const currentGroupIndex = filteredGroups.findIndex(
|
// Find the last group where timestamp <= currentTime
|
||||||
(group) => group.timestamp >= currentTime,
|
let currentGroupIndex = -1;
|
||||||
);
|
for (let i = filteredGroups.length - 1; i >= 0; i--) {
|
||||||
|
if (filteredGroups[i].timestamp <= currentTime) {
|
||||||
|
currentGroupIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (currentGroupIndex !== -1) {
|
if (currentGroupIndex !== -1) {
|
||||||
const element = scrollRef.current.children[
|
const element = scrollRef.current.children[
|
||||||
@ -72,7 +82,7 @@ export default function ActivityStream({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [currentTime, filteredGroups]);
|
}, [filteredGroups, currentTime]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user