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
@@ -23,6 +23,7 @@ const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
const [initialized, setInitialized] = useState<boolean>(false);
const [me, setMe] = useState<Me>();
const [versions, setVersions] = useState<VersionsResponse>();
const [systemName, setSystemName] = useState<string>();
const { send: sendVerifyAuthorization } = useRequest(verifyAuthorization(), {
immediate: false
@@ -33,7 +34,9 @@ const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
{ immediate: false }
)
.onSuccess((event) => {
setVersions(event.data as VersionsResponse);
const response = event.data as VersionsResponse;
setVersions(response);
setSystemName(response.system_name);
})
.onError(() => {
setVersions(undefined);
@@ -60,6 +63,7 @@ const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
AuthenticationApi.clearAccessToken();
setMe(undefined);
setVersions(undefined);
setSystemName(undefined);
if (doRedirect) {
void navigate('/', { replace: true });
}
@@ -96,8 +100,10 @@ const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
signOut,
refresh,
refreshVersions,
setSystemName,
...(me && { me }),
...(versions && { versions })
...(versions && { versions }),
...(systemName !== undefined && { systemName })
}}
>
{children}