diff --git a/web/src/components/overlay/dialog/SearchFilterDialog.tsx b/web/src/components/overlay/dialog/SearchFilterDialog.tsx index e3c54e021..2e3955ee4 100644 --- a/web/src/components/overlay/dialog/SearchFilterDialog.tsx +++ b/web/src/components/overlay/dialog/SearchFilterDialog.tsx @@ -64,6 +64,9 @@ export default function SearchFilterDialog({ const { t } = useTranslation(["components/filter"]); const [currentFilter, setCurrentFilter] = useState(filter ?? {}); const { data: allSubLabels } = useSWR(["sub_labels", { split_joined: 1 }]); + const { data: allRecognizedLicensePlates } = useSWR( + "recognized_license_plates", + ); useEffect(() => { if (filter) { @@ -130,6 +133,7 @@ export default function SearchFilterDialog({ } /> setCurrentFilter({ @@ -875,6 +879,7 @@ export function SnapshotClipFilterContent({ } type RecognizedLicensePlatesFilterContentProps = { + allRecognizedLicensePlates: string[] | undefined; recognizedLicensePlates: string[] | undefined; setRecognizedLicensePlates: ( recognizedLicensePlates: string[] | undefined, @@ -882,18 +887,12 @@ type RecognizedLicensePlatesFilterContentProps = { }; export function RecognizedLicensePlatesFilterContent({ + allRecognizedLicensePlates, recognizedLicensePlates, setRecognizedLicensePlates, }: RecognizedLicensePlatesFilterContentProps) { const { t } = useTranslation(["components/filter"]); - const { data: allRecognizedLicensePlates, error } = useSWR( - "recognized_license_plates", - { - revalidateOnFocus: false, - }, - ); - const [selectedRecognizedLicensePlates, setSelectedRecognizedLicensePlates] = useState(recognizedLicensePlates || []); const [inputValue, setInputValue] = useState(""); @@ -923,7 +922,7 @@ export function RecognizedLicensePlatesFilterContent({ } }; - if (!allRecognizedLicensePlates || allRecognizedLicensePlates.length === 0) { + if (allRecognizedLicensePlates && allRecognizedLicensePlates.length === 0) { return null; } @@ -947,15 +946,11 @@ export function RecognizedLicensePlatesFilterContent({
{t("recognizedLicensePlates.title")}
- {error ? ( -

- {t("recognizedLicensePlates.loadFailed")} -

- ) : !allRecognizedLicensePlates ? ( + {allRecognizedLicensePlates == undefined ? (

{t("recognizedLicensePlates.loading")}

- ) : ( + ) : allRecognizedLicensePlates.length === 0 ? null : ( <>