mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-07 20:41:13 +03:00
Fix unsaved-changes guard, custom path leak, and post-failure cache resync
This commit is contained in:
parent
5b52564619
commit
7126428307
@ -87,6 +87,14 @@ const deriveInitialState = (config: FrigateConfig): PageState => {
|
|||||||
string,
|
string,
|
||||||
unknown
|
unknown
|
||||||
>;
|
>;
|
||||||
|
// Don't carry a Plus path into the Custom tab — it would silently re-save
|
||||||
|
// the same Plus model when the user thinks they switched modes.
|
||||||
|
if (
|
||||||
|
typeof modelWithoutPlus.path === "string" &&
|
||||||
|
modelWithoutPlus.path.startsWith("plus://")
|
||||||
|
) {
|
||||||
|
delete modelWithoutPlus.path;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
detectors: (config.detectors ?? {}) as ConfigSectionData,
|
detectors: (config.detectors ?? {}) as ConfigSectionData,
|
||||||
@ -96,9 +104,9 @@ const deriveInitialState = (config: FrigateConfig): PageState => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function DetectorsAndModelSettingsView(
|
export default function DetectorsAndModelSettingsView({
|
||||||
_props: SettingsPageProps,
|
setUnsavedChanges,
|
||||||
) {
|
}: SettingsPageProps) {
|
||||||
const { t } = useTranslation(["views/settings", "common"]);
|
const { t } = useTranslation(["views/settings", "common"]);
|
||||||
const { getLocaleDocUrl } = useDocDomain();
|
const { getLocaleDocUrl } = useDocDomain();
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
@ -254,6 +262,7 @@ export default function DetectorsAndModelSettingsView(
|
|||||||
} else {
|
} else {
|
||||||
removeMessage(STATUS_BAR_KEY, STATUS_BAR_KEY);
|
removeMessage(STATUS_BAR_KEY, STATUS_BAR_KEY);
|
||||||
}
|
}
|
||||||
|
setUnsavedChanges?.(isDirty);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isDirty]);
|
}, [isDirty]);
|
||||||
|
|
||||||
@ -319,6 +328,9 @@ export default function DetectorsAndModelSettingsView(
|
|||||||
err.response?.data?.detail ||
|
err.response?.data?.detail ||
|
||||||
t("detectorsAndModel.toast.saveError");
|
t("detectorsAndModel.toast.saveError");
|
||||||
toast.error(message, { position: "top-center" });
|
toast.error(message, { position: "top-center" });
|
||||||
|
// Re-sync the config cache in case the two-step PUT left the backend
|
||||||
|
// ahead of the frontend (e.g. step 1 cleared `model` but step 2 failed).
|
||||||
|
await globalMutate("config");
|
||||||
} finally {
|
} finally {
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user