From 9cd3beca4d29c346d4a5fe0002da3dc2e7b80da8 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 24 Jul 2025 21:35:58 +0300 Subject: [PATCH] Make new build weapon select default to "no weapon" rather than Sploosh --- app/features/build-analyzer/analyzer-hooks.ts | 2 +- app/features/build-analyzer/core/utils.ts | 9 ++++++--- .../user-page/routes/u.$identifier.builds.new.tsx | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/features/build-analyzer/analyzer-hooks.ts b/app/features/build-analyzer/analyzer-hooks.ts index f1eabfddb..5016dcbcb 100644 --- a/app/features/build-analyzer/analyzer-hooks.ts +++ b/app/features/build-analyzer/analyzer-hooks.ts @@ -23,7 +23,7 @@ import { export function useAnalyzeBuild() { const [searchParams, setSearchParams] = useSearchParams(); - const mainWeaponId = validatedWeaponIdFromSearchParams(searchParams); + const mainWeaponId = validatedWeaponIdFromSearchParams(searchParams) ?? 0; const build = validatedBuildFromSearchParams(searchParams); const build2 = validatedBuildFromSearchParams(searchParams, "build2", build); const ldeIntensity = validatedLdeIntensityFromSearchParams(searchParams); diff --git a/app/features/build-analyzer/core/utils.ts b/app/features/build-analyzer/core/utils.ts index 1bca273ce..ec0ab3594 100644 --- a/app/features/build-analyzer/core/utils.ts +++ b/app/features/build-analyzer/core/utils.ts @@ -229,12 +229,15 @@ export function validatedAnyWeaponFromSearchParams( return { type: "MAIN", id: id as MainWeaponId }; } - return { type: "MAIN", id: validatedWeaponIdFromSearchParams(searchParams) }; + return { + type: "MAIN", + id: validatedWeaponIdFromSearchParams(searchParams) ?? 0, + }; } export function validatedWeaponIdFromSearchParams( searchParams: URLSearchParams, -): MainWeaponId { +) { const weaponId = searchParams.get("weapon") ? Number(searchParams.get("weapon")) : null; @@ -243,7 +246,7 @@ export function validatedWeaponIdFromSearchParams( return weaponId as MainWeaponId; } - return weaponCategories[0].weaponIds[0]; + return null; } function validateAbility( diff --git a/app/features/user-page/routes/u.$identifier.builds.new.tsx b/app/features/user-page/routes/u.$identifier.builds.new.tsx index 75437b2ed..c10bbc093 100644 --- a/app/features/user-page/routes/u.$identifier.builds.new.tsx +++ b/app/features/user-page/routes/u.$identifier.builds.new.tsx @@ -217,6 +217,7 @@ function WeaponsSelector() { return (
setWeapons((weapons) => { const newWeapons = [...weapons];