mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-14 15:15:22 +03:00
Fix current hour search preview
This commit is contained in:
parent
1df2610b21
commit
09824c19a4
@ -20,7 +20,14 @@ import { cn } from "@/lib/utils";
|
|||||||
import SubFilterIcon from "../icons/SubFilterIcon";
|
import SubFilterIcon from "../icons/SubFilterIcon";
|
||||||
import { FaLocationDot } from "react-icons/fa6";
|
import { FaLocationDot } from "react-icons/fa6";
|
||||||
|
|
||||||
const SEARCH_FILTERS = ["cameras", "date", "general", "zone", "sub"] as const;
|
const SEARCH_FILTERS = [
|
||||||
|
"cameras",
|
||||||
|
"date",
|
||||||
|
"general",
|
||||||
|
"zone",
|
||||||
|
"sub",
|
||||||
|
"source",
|
||||||
|
] as const;
|
||||||
type SearchFilters = (typeof SEARCH_FILTERS)[number];
|
type SearchFilters = (typeof SEARCH_FILTERS)[number];
|
||||||
const DEFAULT_REVIEW_FILTERS: SearchFilters[] = [
|
const DEFAULT_REVIEW_FILTERS: SearchFilters[] = [
|
||||||
"cameras",
|
"cameras",
|
||||||
@ -28,6 +35,7 @@ const DEFAULT_REVIEW_FILTERS: SearchFilters[] = [
|
|||||||
"general",
|
"general",
|
||||||
"zone",
|
"zone",
|
||||||
"sub",
|
"sub",
|
||||||
|
"source",
|
||||||
];
|
];
|
||||||
|
|
||||||
type SearchFilterGroupProps = {
|
type SearchFilterGroupProps = {
|
||||||
@ -175,15 +183,9 @@ export default function SearchFilterGroup({
|
|||||||
<GeneralFilterButton
|
<GeneralFilterButton
|
||||||
allLabels={filterValues.labels}
|
allLabels={filterValues.labels}
|
||||||
selectedLabels={filter?.labels}
|
selectedLabels={filter?.labels}
|
||||||
selectedSearchSources={
|
|
||||||
filter?.search_type ?? ["thumbnail", "description"]
|
|
||||||
}
|
|
||||||
updateLabelFilter={(newLabels) => {
|
updateLabelFilter={(newLabels) => {
|
||||||
onUpdateFilter({ ...filter, labels: newLabels });
|
onUpdateFilter({ ...filter, labels: newLabels });
|
||||||
}}
|
}}
|
||||||
updateSearchSourceFilter={(newSearchSource) =>
|
|
||||||
onUpdateFilter({ ...filter, search_type: newSearchSource })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{filters.includes("zone") && allZones.length > 0 && (
|
{filters.includes("zone") && allZones.length > 0 && (
|
||||||
@ -204,6 +206,16 @@ export default function SearchFilterGroup({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{config?.semantic_search?.enabled && filters.includes("source") && (
|
||||||
|
<SearchTypeButton
|
||||||
|
selectedSearchSources={
|
||||||
|
filter?.search_type ?? ["thumbnail", "description"]
|
||||||
|
}
|
||||||
|
updateSearchSourceFilter={(newSearchSource) =>
|
||||||
|
onUpdateFilter({ ...filter, search_type: newSearchSource })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -211,24 +223,17 @@ export default function SearchFilterGroup({
|
|||||||
type GeneralFilterButtonProps = {
|
type GeneralFilterButtonProps = {
|
||||||
allLabels: string[];
|
allLabels: string[];
|
||||||
selectedLabels: string[] | undefined;
|
selectedLabels: string[] | undefined;
|
||||||
selectedSearchSources: SearchSource[];
|
|
||||||
updateLabelFilter: (labels: string[] | undefined) => void;
|
updateLabelFilter: (labels: string[] | undefined) => void;
|
||||||
updateSearchSourceFilter: (sources: SearchSource[]) => void;
|
|
||||||
};
|
};
|
||||||
function GeneralFilterButton({
|
function GeneralFilterButton({
|
||||||
allLabels,
|
allLabels,
|
||||||
selectedLabels,
|
selectedLabels,
|
||||||
selectedSearchSources,
|
|
||||||
updateLabelFilter,
|
updateLabelFilter,
|
||||||
updateSearchSourceFilter,
|
|
||||||
}: GeneralFilterButtonProps) {
|
}: GeneralFilterButtonProps) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [currentLabels, setCurrentLabels] = useState<string[] | undefined>(
|
const [currentLabels, setCurrentLabels] = useState<string[] | undefined>(
|
||||||
selectedLabels,
|
selectedLabels,
|
||||||
);
|
);
|
||||||
const [currentSearchSources, setCurrentSearchSources] = useState<
|
|
||||||
SearchSource[]
|
|
||||||
>(selectedSearchSources);
|
|
||||||
|
|
||||||
const trigger = (
|
const trigger = (
|
||||||
<Button
|
<Button
|
||||||
@ -251,12 +256,8 @@ function GeneralFilterButton({
|
|||||||
allLabels={allLabels}
|
allLabels={allLabels}
|
||||||
selectedLabels={selectedLabels}
|
selectedLabels={selectedLabels}
|
||||||
currentLabels={currentLabels}
|
currentLabels={currentLabels}
|
||||||
selectedSearchSources={selectedSearchSources}
|
|
||||||
currentSearchSources={currentSearchSources}
|
|
||||||
setCurrentLabels={setCurrentLabels}
|
setCurrentLabels={setCurrentLabels}
|
||||||
updateLabelFilter={updateLabelFilter}
|
updateLabelFilter={updateLabelFilter}
|
||||||
setCurrentSearchSources={setCurrentSearchSources}
|
|
||||||
updateSearchSourceFilter={updateSearchSourceFilter}
|
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -302,78 +303,21 @@ type GeneralFilterContentProps = {
|
|||||||
allLabels: string[];
|
allLabels: string[];
|
||||||
selectedLabels: string[] | undefined;
|
selectedLabels: string[] | undefined;
|
||||||
currentLabels: string[] | undefined;
|
currentLabels: string[] | undefined;
|
||||||
selectedSearchSources: SearchSource[];
|
|
||||||
currentSearchSources: SearchSource[];
|
|
||||||
updateLabelFilter: (labels: string[] | undefined) => void;
|
updateLabelFilter: (labels: string[] | undefined) => void;
|
||||||
setCurrentLabels: (labels: string[] | undefined) => void;
|
setCurrentLabels: (labels: string[] | undefined) => void;
|
||||||
setCurrentSearchSources: (sources: SearchSource[]) => void;
|
|
||||||
updateSearchSourceFilter: (sources: SearchSource[]) => void;
|
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
};
|
};
|
||||||
export function GeneralFilterContent({
|
export function GeneralFilterContent({
|
||||||
allLabels,
|
allLabels,
|
||||||
selectedLabels,
|
selectedLabels,
|
||||||
currentLabels,
|
currentLabels,
|
||||||
selectedSearchSources,
|
|
||||||
currentSearchSources,
|
|
||||||
updateLabelFilter,
|
updateLabelFilter,
|
||||||
setCurrentLabels,
|
setCurrentLabels,
|
||||||
setCurrentSearchSources,
|
|
||||||
updateSearchSourceFilter,
|
|
||||||
onClose,
|
onClose,
|
||||||
}: GeneralFilterContentProps) {
|
}: GeneralFilterContentProps) {
|
||||||
const { data: config } = useSWR<FrigateConfig>("config", {
|
|
||||||
revalidateOnFocus: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="scrollbar-container h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden">
|
<div className="scrollbar-container h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden">
|
||||||
{config?.semantic_search?.enabled && (
|
|
||||||
<div className="my-2.5 flex flex-col gap-2.5">
|
|
||||||
<FilterSwitch
|
|
||||||
label="Thumbnail Image"
|
|
||||||
isChecked={currentSearchSources?.includes("thumbnail") ?? false}
|
|
||||||
onCheckedChange={(isChecked) => {
|
|
||||||
const updatedSources = currentSearchSources
|
|
||||||
? [...currentSearchSources]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
if (isChecked) {
|
|
||||||
updatedSources.push("thumbnail");
|
|
||||||
setCurrentSearchSources(updatedSources);
|
|
||||||
} else {
|
|
||||||
if (updatedSources.length > 1) {
|
|
||||||
const index = updatedSources.indexOf("thumbnail");
|
|
||||||
if (index !== -1) updatedSources.splice(index, 1);
|
|
||||||
setCurrentSearchSources(updatedSources);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<FilterSwitch
|
|
||||||
label="Description"
|
|
||||||
isChecked={currentSearchSources?.includes("description") ?? false}
|
|
||||||
onCheckedChange={(isChecked) => {
|
|
||||||
const updatedSources = currentSearchSources
|
|
||||||
? [...currentSearchSources]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
if (isChecked) {
|
|
||||||
updatedSources.push("description");
|
|
||||||
setCurrentSearchSources(updatedSources);
|
|
||||||
} else {
|
|
||||||
if (updatedSources.length > 1) {
|
|
||||||
const index = updatedSources.indexOf("description");
|
|
||||||
if (index !== -1) updatedSources.splice(index, 1);
|
|
||||||
setCurrentSearchSources(updatedSources);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="mb-5 mt-2.5 flex items-center justify-between">
|
<div className="mb-5 mt-2.5 flex items-center justify-between">
|
||||||
<Label
|
<Label
|
||||||
className="mx-2 cursor-pointer text-primary"
|
className="mx-2 cursor-pointer text-primary"
|
||||||
@ -427,10 +371,6 @@ export function GeneralFilterContent({
|
|||||||
updateLabelFilter(currentLabels);
|
updateLabelFilter(currentLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedSearchSources != currentSearchSources) {
|
|
||||||
updateSearchSourceFilter(currentSearchSources);
|
|
||||||
}
|
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -800,3 +740,170 @@ export function SubFilterContent({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SearchTypeButtonProps = {
|
||||||
|
selectedSearchSources: SearchSource[];
|
||||||
|
updateSearchSourceFilter: (sources: SearchSource[]) => void;
|
||||||
|
};
|
||||||
|
function SearchTypeButton({
|
||||||
|
selectedSearchSources,
|
||||||
|
updateSearchSourceFilter,
|
||||||
|
}: SearchTypeButtonProps) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [currentSearchSources, setCurrentSearchSources] = useState<
|
||||||
|
SearchSource[]
|
||||||
|
>(selectedSearchSources);
|
||||||
|
|
||||||
|
const trigger = (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant={selectedSearchSources?.length != 2 ? "select" : "default"}
|
||||||
|
className="flex items-center gap-2 capitalize"
|
||||||
|
>
|
||||||
|
<FaFilter
|
||||||
|
className={`${selectedSearchSources?.length != 2 ? "text-selected-foreground" : "text-secondary-foreground"}`}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={`hidden md:block ${selectedSearchSources?.length != 2 ? "text-selected-foreground" : "text-primary"}`}
|
||||||
|
>
|
||||||
|
{selectedSearchSources?.length != 2
|
||||||
|
? `${selectedSearchSources[0]}`
|
||||||
|
: "All Search Sources"}
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
const content = (
|
||||||
|
<SearchTypeContent
|
||||||
|
selectedSearchSources={selectedSearchSources}
|
||||||
|
currentSearchSources={currentSearchSources}
|
||||||
|
setCurrentSearchSources={setCurrentSearchSources}
|
||||||
|
updateSearchSourceFilter={updateSearchSourceFilter}
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isMobile) {
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
setCurrentSearchSources(selectedSearchSources);
|
||||||
|
}
|
||||||
|
|
||||||
|
setOpen(open);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DrawerTrigger asChild>{trigger}</DrawerTrigger>
|
||||||
|
<DrawerContent className="max-h-[75dvh] overflow-hidden">
|
||||||
|
{content}
|
||||||
|
</DrawerContent>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
setCurrentSearchSources(selectedSearchSources);
|
||||||
|
}
|
||||||
|
|
||||||
|
setOpen(open);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PopoverTrigger asChild>{trigger}</PopoverTrigger>
|
||||||
|
<PopoverContent>{content}</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchTypeContentProps = {
|
||||||
|
selectedSearchSources: SearchSource[];
|
||||||
|
currentSearchSources: SearchSource[];
|
||||||
|
setCurrentSearchSources: (sources: SearchSource[]) => void;
|
||||||
|
updateSearchSourceFilter: (sources: SearchSource[]) => void;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
||||||
|
export function SearchTypeContent({
|
||||||
|
selectedSearchSources,
|
||||||
|
currentSearchSources,
|
||||||
|
setCurrentSearchSources,
|
||||||
|
updateSearchSourceFilter,
|
||||||
|
onClose,
|
||||||
|
}: SearchTypeContentProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="scrollbar-container h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden">
|
||||||
|
<div className="my-2.5 flex flex-col gap-2.5">
|
||||||
|
<FilterSwitch
|
||||||
|
label="Thumbnail Image"
|
||||||
|
isChecked={currentSearchSources?.includes("thumbnail") ?? false}
|
||||||
|
onCheckedChange={(isChecked) => {
|
||||||
|
const updatedSources = currentSearchSources
|
||||||
|
? [...currentSearchSources]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (isChecked) {
|
||||||
|
updatedSources.push("thumbnail");
|
||||||
|
setCurrentSearchSources(updatedSources);
|
||||||
|
} else {
|
||||||
|
if (updatedSources.length > 1) {
|
||||||
|
const index = updatedSources.indexOf("thumbnail");
|
||||||
|
if (index !== -1) updatedSources.splice(index, 1);
|
||||||
|
setCurrentSearchSources(updatedSources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<FilterSwitch
|
||||||
|
label="Description"
|
||||||
|
isChecked={currentSearchSources?.includes("description") ?? false}
|
||||||
|
onCheckedChange={(isChecked) => {
|
||||||
|
const updatedSources = currentSearchSources
|
||||||
|
? [...currentSearchSources]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (isChecked) {
|
||||||
|
updatedSources.push("description");
|
||||||
|
setCurrentSearchSources(updatedSources);
|
||||||
|
} else {
|
||||||
|
if (updatedSources.length > 1) {
|
||||||
|
const index = updatedSources.indexOf("description");
|
||||||
|
if (index !== -1) updatedSources.splice(index, 1);
|
||||||
|
setCurrentSearchSources(updatedSources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<div className="flex items-center justify-evenly p-2">
|
||||||
|
<Button
|
||||||
|
variant="select"
|
||||||
|
onClick={() => {
|
||||||
|
if (selectedSearchSources != currentSearchSources) {
|
||||||
|
updateSearchSourceFilter(currentSearchSources);
|
||||||
|
}
|
||||||
|
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Apply
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentSearchSources([
|
||||||
|
"thumbnail",
|
||||||
|
"description",
|
||||||
|
] as SearchSource[]);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@ -329,7 +329,9 @@ function PreviewContent({
|
|||||||
} else if (isCurrentHour(review.start_time)) {
|
} else if (isCurrentHour(review.start_time)) {
|
||||||
return (
|
return (
|
||||||
<InProgressPreview
|
<InProgressPreview
|
||||||
review={review}
|
camera={review.camera}
|
||||||
|
startTime={review.start_time}
|
||||||
|
endTime={review.end_time}
|
||||||
timeRange={timeRange}
|
timeRange={timeRange}
|
||||||
setReviewed={setReviewed}
|
setReviewed={setReviewed}
|
||||||
setIgnoreClick={setIgnoreClick}
|
setIgnoreClick={setIgnoreClick}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
|||||||
import ImageLoadingIndicator from "../indicators/ImageLoadingIndicator";
|
import ImageLoadingIndicator from "../indicators/ImageLoadingIndicator";
|
||||||
import ActivityIndicator from "../indicators/activity-indicator";
|
import ActivityIndicator from "../indicators/activity-indicator";
|
||||||
import { capitalizeFirstLetter } from "@/utils/stringUtil";
|
import { capitalizeFirstLetter } from "@/utils/stringUtil";
|
||||||
import { VideoPreview } from "../preview/ScrubbablePreview";
|
import { InProgressPreview, VideoPreview } from "../preview/ScrubbablePreview";
|
||||||
import { Preview } from "@/types/preview";
|
import { Preview } from "@/types/preview";
|
||||||
import { SearchResult } from "@/types/search";
|
import { SearchResult } from "@/types/search";
|
||||||
import useContextMenu from "@/hooks/use-contextmenu";
|
import useContextMenu from "@/hooks/use-contextmenu";
|
||||||
@ -272,6 +272,7 @@ function PreviewContent({
|
|||||||
onTimeUpdate,
|
onTimeUpdate,
|
||||||
}: PreviewContentProps) {
|
}: PreviewContentProps) {
|
||||||
// preview
|
// preview
|
||||||
|
const now = useMemo(() => Date.now() / 1000, []);
|
||||||
|
|
||||||
if (relevantPreview) {
|
if (relevantPreview) {
|
||||||
return (
|
return (
|
||||||
@ -287,6 +288,21 @@ function PreviewContent({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (isCurrentHour(searchResult.start_time)) {
|
} else if (isCurrentHour(searchResult.start_time)) {
|
||||||
return <div />;
|
return (
|
||||||
|
<InProgressPreview
|
||||||
|
camera={searchResult.camera}
|
||||||
|
startTime={searchResult.start_time}
|
||||||
|
endTime={searchResult.end_time}
|
||||||
|
timeRange={{
|
||||||
|
before: now,
|
||||||
|
after: searchResult.start_time,
|
||||||
|
}}
|
||||||
|
setIgnoreClick={setIgnoreClick}
|
||||||
|
isPlayingBack={isPlayingBack}
|
||||||
|
onTimeUpdate={onTimeUpdate}
|
||||||
|
windowVisible={true}
|
||||||
|
setReviewed={() => {}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useApiHost } from "@/api";
|
import { useApiHost } from "@/api";
|
||||||
import { ReviewSegment } from "@/types/review";
|
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { isFirefox, isMobile, isSafari } from "react-device-detect";
|
import { isFirefox, isMobile, isSafari } from "react-device-detect";
|
||||||
import { TimelineScrubMode, TimeRange } from "@/types/timeline";
|
import { TimelineScrubMode, TimeRange } from "@/types/timeline";
|
||||||
@ -286,21 +285,27 @@ export function VideoPreview({
|
|||||||
|
|
||||||
const MIN_LOAD_TIMEOUT_MS = 200;
|
const MIN_LOAD_TIMEOUT_MS = 200;
|
||||||
type InProgressPreviewProps = {
|
type InProgressPreviewProps = {
|
||||||
review: ReviewSegment;
|
camera: string;
|
||||||
|
startTime: number;
|
||||||
|
endTime?: number;
|
||||||
timeRange: TimeRange;
|
timeRange: TimeRange;
|
||||||
showProgress?: boolean;
|
showProgress?: boolean;
|
||||||
loop?: boolean;
|
loop?: boolean;
|
||||||
setReviewed: (reviewId: string) => void;
|
defaultImageUrl?: string;
|
||||||
|
setReviewed: () => void;
|
||||||
setIgnoreClick: (ignore: boolean) => void;
|
setIgnoreClick: (ignore: boolean) => void;
|
||||||
isPlayingBack: (ended: boolean) => void;
|
isPlayingBack: (ended: boolean) => void;
|
||||||
onTimeUpdate?: (time: number | undefined) => void;
|
onTimeUpdate?: (time: number | undefined) => void;
|
||||||
windowVisible: boolean;
|
windowVisible: boolean;
|
||||||
};
|
};
|
||||||
export function InProgressPreview({
|
export function InProgressPreview({
|
||||||
review,
|
camera,
|
||||||
|
startTime,
|
||||||
|
endTime,
|
||||||
timeRange,
|
timeRange,
|
||||||
showProgress = true,
|
showProgress = true,
|
||||||
loop = false,
|
loop = false,
|
||||||
|
defaultImageUrl,
|
||||||
setReviewed,
|
setReviewed,
|
||||||
setIgnoreClick,
|
setIgnoreClick,
|
||||||
isPlayingBack,
|
isPlayingBack,
|
||||||
@ -310,8 +315,8 @@ export function InProgressPreview({
|
|||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const sliderRef = useRef<HTMLDivElement | null>(null);
|
const sliderRef = useRef<HTMLDivElement | null>(null);
|
||||||
const { data: previewFrames } = useSWR<string[]>(
|
const { data: previewFrames } = useSWR<string[]>(
|
||||||
`preview/${review.camera}/start/${Math.floor(review.start_time) - PREVIEW_PADDING}/end/${
|
`preview/${camera}/start/${Math.floor(startTime) - PREVIEW_PADDING}/end/${
|
||||||
Math.ceil(review.end_time ?? timeRange.before) + PREVIEW_PADDING
|
Math.ceil(endTime ?? timeRange.before) + PREVIEW_PADDING
|
||||||
}/frames`,
|
}/frames`,
|
||||||
{ revalidateOnFocus: false },
|
{ revalidateOnFocus: false },
|
||||||
);
|
);
|
||||||
@ -326,7 +331,7 @@ export function InProgressPreview({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (onTimeUpdate) {
|
if (onTimeUpdate) {
|
||||||
onTimeUpdate(review.start_time - PREVIEW_PADDING + key);
|
onTimeUpdate(startTime - PREVIEW_PADDING + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playbackMode != "auto") {
|
if (playbackMode != "auto") {
|
||||||
@ -334,9 +339,7 @@ export function InProgressPreview({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key == previewFrames.length - 1) {
|
if (key == previewFrames.length - 1) {
|
||||||
if (!review.has_been_reviewed) {
|
setReviewed();
|
||||||
setReviewed(review.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loop) {
|
if (loop) {
|
||||||
setKey(0);
|
setKey(0);
|
||||||
@ -356,7 +359,7 @@ export function InProgressPreview({
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (setReviewed && key == Math.floor(previewFrames.length / 2)) {
|
if (setReviewed && key == Math.floor(previewFrames.length / 2)) {
|
||||||
setReviewed(review.id);
|
setReviewed();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previewFrames[key + 1]) {
|
if (previewFrames[key + 1]) {
|
||||||
@ -377,11 +380,7 @@ export function InProgressPreview({
|
|||||||
const onManualSeek = useCallback(
|
const onManualSeek = useCallback(
|
||||||
(values: number[]) => {
|
(values: number[]) => {
|
||||||
const value = values[0];
|
const value = values[0];
|
||||||
|
setReviewed();
|
||||||
if (!review.has_been_reviewed) {
|
|
||||||
setReviewed(review.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
setKey(value);
|
setKey(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -424,7 +423,7 @@ export function InProgressPreview({
|
|||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
className="size-full"
|
className="size-full"
|
||||||
src={`${apiHost}${review.thumb_path.replace("/media/frigate/", "")}`}
|
src={defaultImageUrl} //{`${apiHost}${review.thumb_path.replace("/media/frigate/", "")}`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user