mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
regenerate description fixes (#13940)
This commit is contained in:
parent
7854e1c2c1
commit
1ae521f560
@ -293,7 +293,7 @@ function ObjectDetailsTab({
|
|||||||
typeof key === "string" &&
|
typeof key === "string" &&
|
||||||
(key.includes("events") ||
|
(key.includes("events") ||
|
||||||
key.includes("events/search") ||
|
key.includes("events/search") ||
|
||||||
key.includes("explore")),
|
key.includes("events/explore")),
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
@ -135,7 +135,7 @@ export default function Explore() {
|
|||||||
setIsSlowLoading(true);
|
setIsSlowLoading(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadingTimeout: 10000,
|
loadingTimeout: 15000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const searchResults = useMemo(
|
const searchResults = useMemo(
|
||||||
|
@ -15,12 +15,18 @@ import { SearchResult } from "@/types/search";
|
|||||||
import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator";
|
import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator";
|
||||||
import useImageLoaded from "@/hooks/use-image-loaded";
|
import useImageLoaded from "@/hooks/use-image-loaded";
|
||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
|
import { useEventUpdate } from "@/api/ws";
|
||||||
|
import { isEqual } from "lodash";
|
||||||
|
|
||||||
type ExploreViewProps = {
|
type ExploreViewProps = {
|
||||||
onSelectSearch: (searchResult: SearchResult, index: number) => void;
|
searchDetail: SearchResult | undefined;
|
||||||
|
setSearchDetail: (search: SearchResult | undefined) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ExploreView({ onSelectSearch }: ExploreViewProps) {
|
export default function ExploreView({
|
||||||
|
searchDetail,
|
||||||
|
setSearchDetail,
|
||||||
|
}: ExploreViewProps) {
|
||||||
// title
|
// title
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -29,7 +35,7 @@ export default function ExploreView({ onSelectSearch }: ExploreViewProps) {
|
|||||||
|
|
||||||
// data
|
// data
|
||||||
|
|
||||||
const { data: events } = useSWR<SearchResult[]>(
|
const { data: events, mutate } = useSWR<SearchResult[]>(
|
||||||
[
|
[
|
||||||
"events/explore",
|
"events/explore",
|
||||||
{
|
{
|
||||||
@ -53,6 +59,28 @@ export default function ExploreView({ onSelectSearch }: ExploreViewProps) {
|
|||||||
}, {});
|
}, {});
|
||||||
}, [events]);
|
}, [events]);
|
||||||
|
|
||||||
|
const eventUpdate = useEventUpdate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
mutate();
|
||||||
|
// mutate / revalidate when event description updates come in
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [eventUpdate]);
|
||||||
|
|
||||||
|
// update search detail when results change
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (searchDetail && events) {
|
||||||
|
const updatedSearchDetail = events.find(
|
||||||
|
(result) => result.id === searchDetail.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (updatedSearchDetail && !isEqual(updatedSearchDetail, searchDetail)) {
|
||||||
|
setSearchDetail(updatedSearchDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [events, searchDetail, setSearchDetail]);
|
||||||
|
|
||||||
if (!events) {
|
if (!events) {
|
||||||
return (
|
return (
|
||||||
<ActivityIndicator className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
|
<ActivityIndicator className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
|
||||||
@ -66,7 +94,7 @@ export default function ExploreView({ onSelectSearch }: ExploreViewProps) {
|
|||||||
key={label}
|
key={label}
|
||||||
searchResults={filteredEvents}
|
searchResults={filteredEvents}
|
||||||
objectType={label}
|
objectType={label}
|
||||||
onSelectSearch={onSelectSearch}
|
setSearchDetail={setSearchDetail}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@ -76,13 +104,13 @@ export default function ExploreView({ onSelectSearch }: ExploreViewProps) {
|
|||||||
type ThumbnailRowType = {
|
type ThumbnailRowType = {
|
||||||
objectType: string;
|
objectType: string;
|
||||||
searchResults?: SearchResult[];
|
searchResults?: SearchResult[];
|
||||||
onSelectSearch: (searchResult: SearchResult, index: number) => void;
|
setSearchDetail: (search: SearchResult | undefined) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
function ThumbnailRow({
|
function ThumbnailRow({
|
||||||
objectType,
|
objectType,
|
||||||
searchResults,
|
searchResults,
|
||||||
onSelectSearch,
|
setSearchDetail,
|
||||||
}: ThumbnailRowType) {
|
}: ThumbnailRowType) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@ -116,7 +144,7 @@ function ThumbnailRow({
|
|||||||
>
|
>
|
||||||
<ExploreThumbnailImage
|
<ExploreThumbnailImage
|
||||||
event={event}
|
event={event}
|
||||||
onSelectSearch={onSelectSearch}
|
setSearchDetail={setSearchDetail}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@ -145,11 +173,11 @@ function ThumbnailRow({
|
|||||||
|
|
||||||
type ExploreThumbnailImageProps = {
|
type ExploreThumbnailImageProps = {
|
||||||
event: SearchResult;
|
event: SearchResult;
|
||||||
onSelectSearch: (searchResult: SearchResult, index: number) => void;
|
setSearchDetail: (search: SearchResult | undefined) => void;
|
||||||
};
|
};
|
||||||
function ExploreThumbnailImage({
|
function ExploreThumbnailImage({
|
||||||
event,
|
event,
|
||||||
onSelectSearch,
|
setSearchDetail,
|
||||||
}: ExploreThumbnailImageProps) {
|
}: ExploreThumbnailImageProps) {
|
||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const [imgRef, imgLoaded, onImgLoad] = useImageLoaded();
|
const [imgRef, imgLoaded, onImgLoad] = useImageLoaded();
|
||||||
@ -176,7 +204,7 @@ function ExploreThumbnailImage({
|
|||||||
loading={isSafari ? "eager" : "lazy"}
|
loading={isSafari ? "eager" : "lazy"}
|
||||||
draggable={false}
|
draggable={false}
|
||||||
src={`${apiHost}api/events/${event.id}/thumbnail.jpg`}
|
src={`${apiHost}api/events/${event.id}/thumbnail.jpg`}
|
||||||
onClick={() => onSelectSearch(event, 0)}
|
onClick={() => setSearchDetail(event)}
|
||||||
onLoad={() => {
|
onLoad={() => {
|
||||||
onImgLoad();
|
onImgLoad();
|
||||||
}}
|
}}
|
||||||
|
@ -398,7 +398,10 @@ export default function SearchView({
|
|||||||
Object.keys(searchFilter).length === 0 &&
|
Object.keys(searchFilter).length === 0 &&
|
||||||
!searchTerm && (
|
!searchTerm && (
|
||||||
<div className="scrollbar-container flex size-full flex-col overflow-y-auto">
|
<div className="scrollbar-container flex size-full flex-col overflow-y-auto">
|
||||||
<ExploreView onSelectSearch={onSelectSearch} />
|
<ExploreView
|
||||||
|
searchDetail={searchDetail}
|
||||||
|
setSearchDetail={setSearchDetail}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user