mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
don't load metadata until image has loaded
This commit is contained in:
parent
2fd7fe7928
commit
1d780390d7
@ -20,7 +20,6 @@ import { LuCheckSquare, LuFileUp, LuTrash } from "react-icons/lu";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useFormattedTimestamp } from "@/hooks/use-date-utils";
|
import { useFormattedTimestamp } from "@/hooks/use-date-utils";
|
||||||
import { Skeleton } from "../ui/skeleton";
|
import { Skeleton } from "../ui/skeleton";
|
||||||
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
||||||
|
|
||||||
type PreviewPlayerProps = {
|
type PreviewPlayerProps = {
|
||||||
review: ReviewSegment;
|
review: ReviewSegment;
|
||||||
@ -122,48 +121,53 @@ export default function PreviewThumbnailPlayer({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<LazyLoadImage
|
{!imgLoaded && (
|
||||||
className={`w-full h-full transition-opacity ${
|
<Skeleton className={`absolute inset-0 w-full h-full`} />
|
||||||
playingBack ? "opacity-0" : "opacity-100"
|
|
||||||
}`}
|
|
||||||
src={`${apiHost}${review.thumb_path.replace(
|
|
||||||
"/media/frigate/",
|
|
||||||
""
|
|
||||||
)}`}
|
|
||||||
onLoad={() => {
|
|
||||||
setImgLoaded(true);
|
|
||||||
}}
|
|
||||||
placeholder={<Skeleton className="w-full h-full rounded-xl" />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{!playingBack && imgLoaded && (
|
|
||||||
<>
|
|
||||||
<div className="absolute top-0 left-0 right-0 rounded-t-l z-10 w-full h-[30%] bg-gradient-to-b from-black/60 to-transparent pointer-events-none animate-in fade-in">
|
|
||||||
<div className="flex h-full justify-between items-start mx-3 pb-1 text-white text-sm ">
|
|
||||||
{(review.severity == "alert" ||
|
|
||||||
review.severity == "detection") && (
|
|
||||||
<Chip className="absolute top-2 left-2 flex gap-1 bg-gradient-to-br from-gray-400 to-gray-500 bg-gray-500 z-0">
|
|
||||||
{review.data.objects.map((object) => {
|
|
||||||
return getIconForLabel(object, "w-3 h-3 text-white");
|
|
||||||
})}
|
|
||||||
{review.data.audio.map((audio) => {
|
|
||||||
return getIconForLabel(audio, "w-3 h-3 text-white");
|
|
||||||
})}
|
|
||||||
{review.data.sub_labels?.map((sub) => {
|
|
||||||
return getIconForSubLabel(sub, "w-3 h-3 text-white");
|
|
||||||
})}
|
|
||||||
</Chip>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="absolute bottom-0 left-0 right-0 rounded-b-l z-10 w-full h-[20%] bg-gradient-to-t from-black/60 to-transparent pointer-events-none animate-in fade-in">
|
|
||||||
<div className="flex h-full justify-between items-end mx-3 pb-1 text-white text-sm ">
|
|
||||||
<TimeAgo time={review.start_time * 1000} dense />
|
|
||||||
{formattedDate}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
<div className={`${imgLoaded ? "vislble" : "invisible"}`}>
|
||||||
|
<img
|
||||||
|
className={`w-full h-full transition-opacity ${
|
||||||
|
playingBack ? "opacity-0" : "opacity-100"
|
||||||
|
}`}
|
||||||
|
src={`${apiHost}${review.thumb_path.replace(
|
||||||
|
"/media/frigate/",
|
||||||
|
""
|
||||||
|
)}`}
|
||||||
|
loading="lazy"
|
||||||
|
onLoad={() => {
|
||||||
|
setImgLoaded(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{!playingBack && (
|
||||||
|
<>
|
||||||
|
<div className="absolute top-0 left-0 right-0 rounded-t-l z-10 w-full h-[30%] bg-gradient-to-b from-black/60 to-transparent pointer-events-none">
|
||||||
|
<div className="flex h-full justify-between items-start mx-3 pb-1 text-white text-sm ">
|
||||||
|
{(review.severity == "alert" ||
|
||||||
|
review.severity == "detection") && (
|
||||||
|
<Chip className="absolute top-2 left-2 flex gap-1 bg-gradient-to-br from-gray-400 to-gray-500 bg-gray-500 z-0">
|
||||||
|
{review.data.objects.map((object) => {
|
||||||
|
return getIconForLabel(object, "w-3 h-3 text-white");
|
||||||
|
})}
|
||||||
|
{review.data.audio.map((audio) => {
|
||||||
|
return getIconForLabel(audio, "w-3 h-3 text-white");
|
||||||
|
})}
|
||||||
|
{review.data.sub_labels?.map((sub) => {
|
||||||
|
return getIconForSubLabel(sub, "w-3 h-3 text-white");
|
||||||
|
})}
|
||||||
|
</Chip>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="absolute bottom-0 left-0 right-0 rounded-b-l z-10 w-full h-[20%] bg-gradient-to-t from-black/60 to-transparent pointer-events-none">
|
||||||
|
<div className="flex h-full justify-between items-end mx-3 pb-1 text-white text-sm ">
|
||||||
|
<TimeAgo time={review.start_time * 1000} dense />
|
||||||
|
{formattedDate}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
{playingBack && (
|
{playingBack && (
|
||||||
<Slider
|
<Slider
|
||||||
className="absolute left-0 right-0 bottom-0 z-10"
|
className="absolute left-0 right-0 bottom-0 z-10"
|
||||||
@ -358,7 +362,7 @@ function InProgressPreview({
|
|||||||
|
|
||||||
if (!previewFrames || previewFrames.length == 0) {
|
if (!previewFrames || previewFrames.length == 0) {
|
||||||
return (
|
return (
|
||||||
<LazyLoadImage
|
<img
|
||||||
className="h-full w-full"
|
className="h-full w-full"
|
||||||
src={`${apiHost}${review.thumb_path.replace("/media/frigate/", "")}`}
|
src={`${apiHost}${review.thumb_path.replace("/media/frigate/", "")}`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user