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,10 +1,8 @@
import { memo } from 'react';
import { memo, useContext } from 'react';
import { Box, Divider, Drawer, Toolbar, Typography, styled } from '@mui/material';
import { readSettings } from 'api/app';
import { useRequest } from 'alova/client';
import { AuthenticatedContext } from 'contexts/authentication';
import { PROJECT_NAME } from 'env';
import { DRAWER_WIDTH } from './Layout';
@@ -27,8 +25,7 @@ interface LayoutDrawerProps {
}
const LayoutDrawerComponent = ({ mobileOpen, onClose }: LayoutDrawerProps) => {
const { data: settings } = useRequest(readSettings);
const system_name = settings?.system_name;
const { systemName } = useContext(AuthenticatedContext);
const drawer = (
<>
@@ -43,9 +40,9 @@ const LayoutDrawerComponent = ({ mobileOpen, onClose }: LayoutDrawerProps) => {
}}
>
<Typography>{PROJECT_NAME}</Typography>
{system_name && (
{systemName && (
<Typography color="secondary" variant="body2">
{system_name}
{systemName}
</Typography>
)}
</Box>