From a9941af621504c40a3f1879ed3a7574c287d8f27 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 23 Nov 2022 16:49:34 -0500 Subject: [PATCH] fix(striker-ui): include previous data in ConfigPeersForm --- .../StrikerConfig/ConfigPeersForm.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx b/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx index a1e6deea..26b2ca0a 100644 --- a/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx +++ b/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx @@ -43,11 +43,11 @@ const ConfigPeersForm: FC = ({ const apiMessageElement = useMemo( () => - apiMessage ? ( + apiMessage && ( - ) : undefined, + ), [apiMessage], ); @@ -67,13 +67,14 @@ const ConfigPeersForm: FC = ({ peer, }, }) => { - setInboundConnections( + setInboundConnections((previous) => Object.entries(ipAddressList).reduce( ( - previous, + nyu, [ipAddress, { networkLinkNumber, networkNumber, networkType }], ) => { - previous[ipAddress] = { + nyu[ipAddress] = { + ...previous[ipAddress], dbPort, dbUser, ipAddress, @@ -82,16 +83,16 @@ const ConfigPeersForm: FC = ({ networkType, }; - return previous; + return nyu; }, {}, ), ); - setPeerConnections( + setPeerConnections((previous) => Object.entries(peer).reduce( ( - previous, + nyu, [ peerIPAddress, { @@ -102,7 +103,10 @@ const ConfigPeersForm: FC = ({ }, ], ) => { - previous[`${peerDBUser}@${peerIPAddress}:${peerDBPort}`] = { + const peerKey = `${peerDBUser}@${peerIPAddress}:${peerDBPort}`; + + nyu[peerKey] = { + ...previous[peerKey], dbPort: peerDBPort, dbUser: peerDBUser, hostUUID, @@ -110,7 +114,7 @@ const ConfigPeersForm: FC = ({ isPingTest, }; - return previous; + return nyu; }, {}, ),