mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-21 15:48:22 +03:00
refactor: add friendly zone names to timeline entries and clean up unused code
This commit is contained in:
parent
06e2fc0aa0
commit
e6b448732d
@ -50,22 +50,23 @@ export function ObjectPath({
|
||||
if (!imgRef.current || !positions) return [];
|
||||
const imgRect = imgRef.current.getBoundingClientRect();
|
||||
return positions.map((pos) => {
|
||||
if (config && pos.lifecycle_item?.data?.zones) {
|
||||
pos.lifecycle_item = {
|
||||
...pos.lifecycle_item,
|
||||
data: {
|
||||
...pos.lifecycle_item.data,
|
||||
zones_friendly_names: pos.lifecycle_item.data.zones.map((zone) => {
|
||||
return resolveZoneName(config, zone);
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
x: pos.x * imgRect.width,
|
||||
y: pos.y * imgRect.height,
|
||||
timestamp: pos.timestamp,
|
||||
lifecycle_item: pos.lifecycle_item,
|
||||
lifecycle_item: pos.lifecycle_item?.data?.zones
|
||||
? {
|
||||
...pos.lifecycle_item,
|
||||
data: {
|
||||
...pos.lifecycle_item?.data,
|
||||
zones_friendly_names: pos.lifecycle_item?.data.zones.map(
|
||||
(zone) => {
|
||||
return resolveZoneName(config, zone);
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
: pos.lifecycle_item,
|
||||
};
|
||||
});
|
||||
}, [imgRef, positions, config]);
|
||||
|
||||
@ -269,6 +269,10 @@ export function PolygonCanvas({
|
||||
const updatedPolygons = [...polygons];
|
||||
const activePolygon = updatedPolygons[activePolygonIndex];
|
||||
|
||||
if (!activePolygon) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add default points order for already completed polygons
|
||||
if (!activePolygon.pointsOrder && activePolygon.isFinished) {
|
||||
updatedPolygons[activePolygonIndex] = {
|
||||
|
||||
@ -655,16 +655,6 @@ function LifecycleItem({
|
||||
const { t } = useTranslation("views/events");
|
||||
const { data: config } = useSWR<FrigateConfig>("config");
|
||||
|
||||
item = {
|
||||
...item,
|
||||
data: {
|
||||
...item.data,
|
||||
zones_friendly_names: item?.data?.zones?.map((zone) => {
|
||||
return resolveZoneName(config, zone);
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
const aspectRatio = useMemo(() => {
|
||||
if (!config || !item?.camera) {
|
||||
return 16 / 9;
|
||||
@ -806,17 +796,28 @@ function ObjectTimeline({
|
||||
},
|
||||
]);
|
||||
|
||||
const { data: config } = useSWR<FrigateConfig>("config");
|
||||
const timeline = useMemo(() => {
|
||||
if (!fullTimeline) {
|
||||
return fullTimeline;
|
||||
}
|
||||
|
||||
return fullTimeline.filter(
|
||||
(t) =>
|
||||
t.timestamp >= review.start_time &&
|
||||
(review.end_time == undefined || t.timestamp <= review.end_time),
|
||||
);
|
||||
}, [fullTimeline, review]);
|
||||
return fullTimeline
|
||||
.filter(
|
||||
(t) =>
|
||||
t.timestamp >= review.start_time &&
|
||||
(review.end_time == undefined || t.timestamp <= review.end_time),
|
||||
)
|
||||
.map((event) => ({
|
||||
...event,
|
||||
data: {
|
||||
...event.data,
|
||||
zones_friendly_names: event.data?.zones?.map((zone) =>
|
||||
resolveZoneName(config, zone),
|
||||
),
|
||||
},
|
||||
}));
|
||||
}, [config, fullTimeline, review]);
|
||||
|
||||
if (isValidating && (!timeline || timeline.length === 0)) {
|
||||
return <ActivityIndicator className="ml-2 size-3" />;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user