mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 07:35:27 +03:00
update search detail when results change
This commit is contained in:
parent
a298b395dd
commit
aff5b3713d
@ -23,6 +23,7 @@ import useKeyboardListener, {
|
|||||||
import scrollIntoView from "scroll-into-view-if-needed";
|
import scrollIntoView from "scroll-into-view-if-needed";
|
||||||
import InputWithTags from "@/components/input/InputWithTags";
|
import InputWithTags from "@/components/input/InputWithTags";
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||||
|
import { isEqual } from "lodash";
|
||||||
|
|
||||||
type SearchViewProps = {
|
type SearchViewProps = {
|
||||||
search: string;
|
search: string;
|
||||||
@ -140,6 +141,21 @@ export default function SearchView({
|
|||||||
setSelectedIndex(index);
|
setSelectedIndex(index);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// update search detail when results change
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (searchDetail && searchResults) {
|
||||||
|
const flattenedResults = searchResults.flat();
|
||||||
|
const updatedSearchDetail = flattenedResults.find(
|
||||||
|
(result) => result.id === searchDetail.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (updatedSearchDetail && !isEqual(updatedSearchDetail, searchDetail)) {
|
||||||
|
setSearchDetail(updatedSearchDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [searchResults, searchDetail]);
|
||||||
|
|
||||||
// confidence score - probably needs tweaking
|
// confidence score - probably needs tweaking
|
||||||
|
|
||||||
const zScoreToConfidence = (score: number, source: string) => {
|
const zScoreToConfidence = (score: number, source: string) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user