From e8d1fe7deda1e52ce7e4a3a0b309f2b776a1df49 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 22 Apr 2023 11:56:27 +0300 Subject: [PATCH] Refactor new build modes input logic --- app/routes/u.$identifier/builds/new.tsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/app/routes/u.$identifier/builds/new.tsx b/app/routes/u.$identifier/builds/new.tsx index 49e8f91ff..1ea8940e5 100644 --- a/app/routes/u.$identifier/builds/new.tsx +++ b/app/routes/u.$identifier/builds/new.tsx @@ -257,17 +257,7 @@ function ModeCheckboxes() { const { buildToEdit } = useLoaderData(); const { t } = useTranslation("builds"); - let currentBuildModes: - | typeof modesShort - | typeof rankedModesShort - | null - | undefined = buildToEdit?.modes; - - // Use the Ranked Modes by default for brand new builds (so that the checkboxes can be checked by default) - // See issue for more info: https://github.com/Sendouc/sendou.ink/issues/1150 - if (!currentBuildModes) { - currentBuildModes = rankedModesShort; - } + const modes = buildToEdit?.modes ?? rankedModesShort; return (
@@ -282,9 +272,7 @@ function ModeCheckboxes() { id={mode} name={mode} type="checkbox" - defaultChecked={currentBuildModes?.some( - (currentMode) => currentMode == mode - )} + defaultChecked={modes.includes(mode)} data-cy={`${mode}-checkbox`} />