fix(striker-ui): include previous data in ConfigPeersForm

main
Tsu-ba-me 2 years ago
parent ab3fe5c625
commit a9941af621
  1. 24
      striker-ui/components/StrikerConfig/ConfigPeersForm.tsx

@ -43,11 +43,11 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
const apiMessageElement = useMemo( const apiMessageElement = useMemo(
() => () =>
apiMessage ? ( apiMessage && (
<Grid item sm={2} xs={1}> <Grid item sm={2} xs={1}>
<MessageBox {...apiMessage} /> <MessageBox {...apiMessage} />
</Grid> </Grid>
) : undefined, ),
[apiMessage], [apiMessage],
); );
@ -67,13 +67,14 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
peer, peer,
}, },
}) => { }) => {
setInboundConnections( setInboundConnections((previous) =>
Object.entries(ipAddressList).reduce<InboundConnectionList>( Object.entries(ipAddressList).reduce<InboundConnectionList>(
( (
previous, nyu,
[ipAddress, { networkLinkNumber, networkNumber, networkType }], [ipAddress, { networkLinkNumber, networkNumber, networkType }],
) => { ) => {
previous[ipAddress] = { nyu[ipAddress] = {
...previous[ipAddress],
dbPort, dbPort,
dbUser, dbUser,
ipAddress, ipAddress,
@ -82,16 +83,16 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
networkType, networkType,
}; };
return previous; return nyu;
}, },
{}, {},
), ),
); );
setPeerConnections( setPeerConnections((previous) =>
Object.entries(peer).reduce<PeerConnectionList>( Object.entries(peer).reduce<PeerConnectionList>(
( (
previous, nyu,
[ [
peerIPAddress, peerIPAddress,
{ {
@ -102,7 +103,10 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
}, },
], ],
) => { ) => {
previous[`${peerDBUser}@${peerIPAddress}:${peerDBPort}`] = { const peerKey = `${peerDBUser}@${peerIPAddress}:${peerDBPort}`;
nyu[peerKey] = {
...previous[peerKey],
dbPort: peerDBPort, dbPort: peerDBPort,
dbUser: peerDBUser, dbUser: peerDBUser,
hostUUID, hostUUID,
@ -110,7 +114,7 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
isPingTest, isPingTest,
}; };
return previous; return nyu;
}, },
{}, {},
), ),

Loading…
Cancel
Save