fix: improve anvil default selection at launch

main
Josue 4 years ago committed by Tsu-ba-me
parent 3d837a3ea7
commit 4fbb61dede
  1. 8
      striker-ui/components/Anvils/AnvilList.tsx

@ -1,4 +1,4 @@
import { useContext } from 'react'; import { useContext, useEffect } from 'react';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import { ClassNameMap } from '@material-ui/styles'; import { ClassNameMap } from '@material-ui/styles';
import { List, Box, Divider, ListItem } from '@material-ui/core'; import { List, Box, Divider, ListItem } from '@material-ui/core';
@ -63,9 +63,13 @@ const selectDecorator = (
}; };
const AnvilList = ({ list }: { list: AnvilListItem[] }): JSX.Element => { const AnvilList = ({ list }: { list: AnvilListItem[] }): JSX.Element => {
const { setAnvilUuid } = useContext(AnvilContext); const { uuid, setAnvilUuid } = useContext(AnvilContext);
const classes = useStyles(); const classes = useStyles();
useEffect(() => {
setAnvilUuid(sortAnvils(list)[0].anvil_uuid);
}, [uuid, list, setAnvilUuid]);
return ( return (
<List component="nav" className={classes.root} aria-label="mailbox folders"> <List component="nav" className={classes.root} aria-label="mailbox folders">
{sortAnvils(list).map((anvil) => { {sortAnvils(list).map((anvil) => {

Loading…
Cancel
Save