fix: make default initialization concurrency-safe

This commit is contained in:
cesnimda
2026-09-22 07:33:51 +02:00
parent 38cf37ef96
commit 57a6bd02c6
4 changed files with 187 additions and 15 deletions
@@ -25,15 +25,19 @@ export default function RulesSettingsCard() {
const [loadError, setLoadError] = useState<string | null>(null);
useEffect(() => {
let active = true;
api.get<RuleSettings>("/rules")
.then((r) => {
if (!active) return;
setS(r.data);
setLoadError(null);
})
.catch((e: any) => {
if (!active) return;
setS(null);
setLoadError(getApiErrorMessage(e, t("rulesLoadFailed")));
});
return () => { active = false; };
}, [t]);
const save = async () => {