get and send system name in AuthenticaionContext to prevent /rest/settings on each render

This commit is contained in:
proddy
2026-08-23 12:22:45 +02:00
parent 6efc7113b3
commit 42f86cd12b
6 changed files with 32 additions and 13 deletions
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useContext, useEffect, useState } from 'react';
import CancelIcon from '@mui/icons-material/Cancel';
import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
@@ -31,6 +31,7 @@ import {
useLayoutTitle
} from 'components';
import { toast } from 'components/toast';
import { AuthenticatedContext } from 'contexts/authentication';
import { useI18nContext } from 'i18n/i18n-react';
import { numberValue, updateValueDirty, useRest } from 'utils';
import { ValidationError, validate } from 'validators';
@@ -68,6 +69,14 @@ const ApplicationSettings = () => {
update: writeSettings
});
// the menu drawer reads the system name from the authentication context
const { setSystemName } = useContext(AuthenticatedContext);
useEffect(() => {
if (origData?.system_name !== undefined) {
setSystemName(origData.system_name);
}
}, [origData?.system_name, setSystemName]);
const [restarting, setRestarting] = useState<boolean>();
const { LL } = useI18nContext();