mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
fix audio label translation in explore filter
This commit is contained in:
parent
25b36a1a7a
commit
e32d250f39
@ -251,11 +251,30 @@ function GeneralFilterButton({
|
|||||||
updateLabelFilter,
|
updateLabelFilter,
|
||||||
}: GeneralFilterButtonProps) {
|
}: GeneralFilterButtonProps) {
|
||||||
const { t } = useTranslation(["components/filter"]);
|
const { t } = useTranslation(["components/filter"]);
|
||||||
|
const { data: config } = useSWR<FrigateConfig>("config", {
|
||||||
|
revalidateOnFocus: false,
|
||||||
|
});
|
||||||
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 allAudioListenLabels = useMemo<Set<string>>(() => {
|
||||||
|
if (!config) {
|
||||||
|
return new Set<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
const labels = new Set<string>();
|
||||||
|
Object.values(config.cameras).forEach((camera) => {
|
||||||
|
if (camera?.audio?.enabled) {
|
||||||
|
camera.audio.listen.forEach((label) => {
|
||||||
|
labels.add(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return labels;
|
||||||
|
}, [config]);
|
||||||
|
|
||||||
const buttonText = useMemo(() => {
|
const buttonText = useMemo(() => {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
return t("labels.all.short");
|
return t("labels.all.short");
|
||||||
@ -266,13 +285,17 @@ function GeneralFilterButton({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedLabels.length == 1) {
|
if (selectedLabels.length == 1) {
|
||||||
return getTranslatedLabel(selectedLabels[0]);
|
const label = selectedLabels[0];
|
||||||
|
return getTranslatedLabel(
|
||||||
|
label,
|
||||||
|
allAudioListenLabels.has(label) ? "audio" : "object",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t("labels.count", {
|
return t("labels.count", {
|
||||||
count: selectedLabels.length,
|
count: selectedLabels.length,
|
||||||
});
|
});
|
||||||
}, [selectedLabels, t]);
|
}, [selectedLabels, allAudioListenLabels, t]);
|
||||||
|
|
||||||
// ui
|
// ui
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user