From 91282daeb2bbf1b31d1d2e2c3b44bf167be8ef0e Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 22 Jun 2021 18:25:11 -0400 Subject: [PATCH] fix: improve server selection in the server component --- striker-ui/components/Servers.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/striker-ui/components/Servers.tsx b/striker-ui/components/Servers.tsx index 127d64f0..abac519a 100644 --- a/striker-ui/components/Servers.tsx +++ b/striker-ui/components/Servers.tsx @@ -103,12 +103,10 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { if (index === -1) { selected.push(server_uuid); setSelected([...selected]); - } else selected.splice(index, 1); - }; - - const isSelected = (server: string): boolean => { - const thing = selected.find((s) => s === server); - return thing !== 'undefined'; + } else { + selected.splice(index, 1); + setSelected([...selected]); + } }; const anvilIndex = anvil.findIndex((a) => a.anvil_uuid === uuid); @@ -175,7 +173,11 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { s === server.server_uuid, + ) !== undefined + } onChange={() => handleChange(server.server_uuid)} inputProps={{ 'aria-label': 'primary checkbox' }} />