fix: admin: on mobile, 'version' was reloaded at each opening of the menu

Massimo Melina committed May 6, 2022 at 12:36 UTC 58a241c7c2db12581ceb75cbf656a216253eea18
1 file changed +4 -2
admin/src/MainMenu.ts
+4 -2
@@ -44,12 +44,14 @@ export const mainMenu: MenuEntry[] = [
44 { path: 'logout', icon: Logout, comp: LogoutPage }
45 ]
46
47 +let version: any // cache 'version', as it won't change at runtime, while the Drawer mechanism will unmount our menu each time
48 export default function Menu({ onSelect }: { onSelect: ()=>void }) {
48 - const [status] = useApi('get_status')
49 + const [status] = useApi(!version && 'get_status')
50 + version ||= status?.version?.replace('-', ' ')
51 return h(List, { sx:{ pr:1, bgcolor: 'primary.main', color:'primary.contrastText', minHeight: '100%', boxSizing: 'border-box' } },
52 h(Box, { display: 'flex', px: 2, py: 1, gap: 2, alignItems: 'flex-end' },
53 h(Typography, { variant:'h3' }, 'HFS'),
52 - h(Box, { pb: 1, fontSize: 'small' }, status?.version?.replace('-', ' ')),
54 + h(Box, { pb: 1, fontSize: 'small' }, version),
55 ),
56 mainMenu.map(it =>
57 h(ListItemButton, {