mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-27 14:19:01 +03:00
Miscellaneous fixes (#23082)
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / AMD64 Build (push) Waiting to run
* openvino log message and preview directory checks * restrict config vars for viewer users * recording timestamp fix when startTime is exactly on an hour boundary, findIndex returns the first matching chunk, which is the previous hour's chunk (where before == startTime), instead of the correct chunk (where after == startTime) the bug shows up when using the share timestamp feature and sharing a specific timestamp on the exact hour mark. when accessing the shared link, the timeline would jump to the incorrect hour * use helper for chunked time range * Adjustments to contributing docs * tweak * Improve wording * tweak --------- Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
This commit is contained in:
co-authored by
Nicolas Mowen
parent
ba4a6a53d7
commit
45213d0420
@@ -38,6 +38,22 @@ export function getChunkedTimeDay(timeRange: TimeRange): TimeRange[] {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the chunk index that contains the given timestamp.
|
||||
* Uses half-open intervals [after, before) for all chunks except the last,
|
||||
* which uses a closed interval [after, before] so the terminal boundary
|
||||
* is always reachable.
|
||||
*/
|
||||
export function findChunkIndex(chunks: TimeRange[], timestamp: number): number {
|
||||
return chunks.findIndex((chunk, i) => {
|
||||
const isLast = i === chunks.length - 1;
|
||||
return (
|
||||
chunk.after <= timestamp &&
|
||||
(isLast ? chunk.before >= timestamp : chunk.before > timestamp)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function getChunkedTimeRange(
|
||||
startTimestamp: number,
|
||||
endTimestamp: number,
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
ReviewSummary,
|
||||
ZoomLevel,
|
||||
} from "@/types/review";
|
||||
import { getChunkedTimeDay } from "@/utils/timelineUtil";
|
||||
import { findChunkIndex, getChunkedTimeDay } from "@/utils/timelineUtil";
|
||||
import {
|
||||
MutableRefObject,
|
||||
useCallback,
|
||||
@@ -169,9 +169,7 @@ export function RecordingView({
|
||||
[timeRange],
|
||||
);
|
||||
const [selectedRangeIdx, setSelectedRangeIdx] = useState(
|
||||
chunkedTimeRange.findIndex((chunk) => {
|
||||
return chunk.after <= startTime && chunk.before >= startTime;
|
||||
}),
|
||||
findChunkIndex(chunkedTimeRange, startTime),
|
||||
);
|
||||
const currentTimeRange = useMemo<TimeRange>(
|
||||
() =>
|
||||
@@ -274,9 +272,7 @@ export function RecordingView({
|
||||
|
||||
const updateSelectedSegment = useCallback(
|
||||
(currentTime: number, updateStartTime: boolean) => {
|
||||
const index = chunkedTimeRange.findIndex(
|
||||
(seg) => seg.after <= currentTime && seg.before >= currentTime,
|
||||
);
|
||||
const index = findChunkIndex(chunkedTimeRange, currentTime);
|
||||
|
||||
if (index != -1) {
|
||||
if (updateStartTime) {
|
||||
|
||||
Reference in New Issue
Block a user