mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-09-13 05:34:34 +00:00
get and send system name in AuthenticaionContext to prevent /rest/settings on each render
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user