mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Recordings Fixes (#13005)
* If recordings don't exist mark as no recordings * Fix reloading recordings failing * Fix mark items not clearing selected * Cleanup * Default to last full hour when error occurs * Remove check * Cleanup * Handle empty recordings list case * Ensure that the start time is within the time range * Catch other reset cases
This commit is contained in:
parent
b2c23a367d
commit
dc04cf82d8
@ -167,7 +167,11 @@ export default function DynamicVideoPlayer({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!controller || !recordings) {
|
if (!controller || !recordings?.length) {
|
||||||
|
if (recordings?.length == 0) {
|
||||||
|
setNoRecording(true);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ export default function Events() {
|
|||||||
|
|
||||||
// review paging
|
// review paging
|
||||||
|
|
||||||
const [beforeTs, setBeforeTs] = useState(Date.now() / 1000);
|
const [beforeTs, setBeforeTs] = useState(Math.ceil(Date.now() / 1000));
|
||||||
const last24Hours = useMemo(() => {
|
const last24Hours = useMemo(() => {
|
||||||
return { before: beforeTs, after: getHoursAgo(24) };
|
return { before: beforeTs, after: getHoursAgo(24) };
|
||||||
}, [beforeTs]);
|
}, [beforeTs]);
|
||||||
@ -455,5 +455,5 @@ export default function Events() {
|
|||||||
function getHoursAgo(hours: number): number {
|
function getHoursAgo(hours: number): number {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
now.setHours(now.getHours() - hours);
|
now.setHours(now.getHours() - hours);
|
||||||
return now.getTime() / 1000;
|
return Math.ceil(now.getTime() / 1000);
|
||||||
}
|
}
|
||||||
|
@ -395,6 +395,7 @@ export default function EventView({
|
|||||||
markAllItemsAsReviewed={markAllItemsAsReviewed}
|
markAllItemsAsReviewed={markAllItemsAsReviewed}
|
||||||
onSelectReview={onSelectReview}
|
onSelectReview={onSelectReview}
|
||||||
onSelectAllReviews={onSelectAllReviews}
|
onSelectAllReviews={onSelectAllReviews}
|
||||||
|
setSelectedReviews={setSelectedReviews}
|
||||||
pullLatestData={pullLatestData}
|
pullLatestData={pullLatestData}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -437,6 +438,7 @@ type DetectionReviewProps = {
|
|||||||
markAllItemsAsReviewed: (currentItems: ReviewSegment[]) => void;
|
markAllItemsAsReviewed: (currentItems: ReviewSegment[]) => void;
|
||||||
onSelectReview: (review: ReviewSegment, ctrl: boolean) => void;
|
onSelectReview: (review: ReviewSegment, ctrl: boolean) => void;
|
||||||
onSelectAllReviews: () => void;
|
onSelectAllReviews: () => void;
|
||||||
|
setSelectedReviews: (reviewIds: string[]) => void;
|
||||||
pullLatestData: () => void;
|
pullLatestData: () => void;
|
||||||
};
|
};
|
||||||
function DetectionReview({
|
function DetectionReview({
|
||||||
@ -455,6 +457,7 @@ function DetectionReview({
|
|||||||
markAllItemsAsReviewed,
|
markAllItemsAsReviewed,
|
||||||
onSelectReview,
|
onSelectReview,
|
||||||
onSelectAllReviews,
|
onSelectAllReviews,
|
||||||
|
setSelectedReviews,
|
||||||
pullLatestData,
|
pullLatestData,
|
||||||
}: DetectionReviewProps) {
|
}: DetectionReviewProps) {
|
||||||
const reviewTimelineRef = useRef<HTMLDivElement>(null);
|
const reviewTimelineRef = useRef<HTMLDivElement>(null);
|
||||||
@ -692,6 +695,7 @@ function DetectionReview({
|
|||||||
className="text-white"
|
className="text-white"
|
||||||
variant="select"
|
variant="select"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setSelectedReviews([]);
|
||||||
markAllItemsAsReviewed(currentItems ?? []);
|
markAllItemsAsReviewed(currentItems ?? []);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -84,7 +84,11 @@ export function RecordingView({
|
|||||||
const previewRowRef = useRef<HTMLDivElement | null>(null);
|
const previewRowRef = useRef<HTMLDivElement | null>(null);
|
||||||
const previewRefs = useRef<{ [camera: string]: PreviewController }>({});
|
const previewRefs = useRef<{ [camera: string]: PreviewController }>({});
|
||||||
|
|
||||||
const [playbackStart, setPlaybackStart] = useState(startTime);
|
const [playbackStart, setPlaybackStart] = useState(
|
||||||
|
startTime >= timeRange.after && startTime <= timeRange.before
|
||||||
|
? startTime
|
||||||
|
: timeRange.before - 60,
|
||||||
|
);
|
||||||
|
|
||||||
const mainCameraReviewItems = useMemo(
|
const mainCameraReviewItems = useMemo(
|
||||||
() => reviewItems?.filter((cam) => cam.camera == mainCamera) ?? [],
|
() => reviewItems?.filter((cam) => cam.camera == mainCamera) ?? [],
|
||||||
@ -107,8 +111,10 @@ export function RecordingView({
|
|||||||
return chunk.after <= startTime && chunk.before >= startTime;
|
return chunk.after <= startTime && chunk.before >= startTime;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const currentTimeRange = useMemo(
|
const currentTimeRange = useMemo<TimeRange>(
|
||||||
() => chunkedTimeRange[selectedRangeIdx],
|
() =>
|
||||||
|
chunkedTimeRange[selectedRangeIdx] ??
|
||||||
|
chunkedTimeRange[chunkedTimeRange.length - 1],
|
||||||
[selectedRangeIdx, chunkedTimeRange],
|
[selectedRangeIdx, chunkedTimeRange],
|
||||||
);
|
);
|
||||||
const reviewFilterList = useMemo(() => {
|
const reviewFilterList = useMemo(() => {
|
||||||
@ -198,6 +204,10 @@ export function RecordingView({
|
|||||||
|
|
||||||
const manuallySetCurrentTime = useCallback(
|
const manuallySetCurrentTime = useCallback(
|
||||||
(time: number) => {
|
(time: number) => {
|
||||||
|
if (!currentTimeRange) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setCurrentTime(time);
|
setCurrentTime(time);
|
||||||
|
|
||||||
if (currentTimeRange.after <= time && currentTimeRange.before >= time) {
|
if (currentTimeRange.after <= time && currentTimeRange.before >= time) {
|
||||||
@ -420,7 +430,18 @@ export function RecordingView({
|
|||||||
filterList={reviewFilterList}
|
filterList={reviewFilterList}
|
||||||
showReviewed
|
showReviewed
|
||||||
setShowReviewed={() => {}}
|
setShowReviewed={() => {}}
|
||||||
onUpdateFilter={updateFilter}
|
onUpdateFilter={(newFilter) => {
|
||||||
|
// if we are resetting the date to last 24 hours
|
||||||
|
// then we need to reset the playbackStart time
|
||||||
|
if (
|
||||||
|
filter?.before != undefined &&
|
||||||
|
newFilter?.before == undefined
|
||||||
|
) {
|
||||||
|
setPlaybackStart(Date.now() / 1000 - 360);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFilter(newFilter);
|
||||||
|
}}
|
||||||
setMotionOnly={() => {}}
|
setMotionOnly={() => {}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user