diff --git a/packages/website/src/components/TankSearch/components/FilterControl.tsx b/packages/website/src/components/TankSearch/components/FilterControl.tsx index 5261b43e4..68ae1e60f 100644 --- a/packages/website/src/components/TankSearch/components/FilterControl.tsx +++ b/packages/website/src/components/TankSearch/components/FilterControl.tsx @@ -5,11 +5,7 @@ import { TankType, TIER_ROMAN_NUMERALS, } from "@blitzkit/core"; -import { - ComponentBooleanIcon, - LockClosedIcon, - LockOpen2Icon, -} from "@radix-ui/react-icons"; +import { LockClosedIcon, LockOpen2Icon } from "@radix-ui/react-icons"; import { Box, Flex, @@ -71,7 +67,9 @@ function ShellFilter({ index, premium }: { index: number; premium?: boolean }) { )} @@ -107,7 +105,9 @@ function ShellFilter({ index, premium }: { index: number; premium?: boolean }) { > @@ -135,29 +135,13 @@ function OwnershipFilter(props: FlexProps) { { TankFilters.mutate((draft) => { - draft.ownership = "all"; - }); - }} - > - - - - { - TankFilters.mutate((draft) => { - draft.ownership = "owned"; + draft.showOwned = !draft.showOwned; }); }} > @@ -167,13 +151,13 @@ function OwnershipFilter(props: FlexProps) { { TankFilters.mutate((draft) => { - draft.ownership = "unowned"; + draft.showUnowned = !draft.showUnowned; }); }} > @@ -579,27 +563,13 @@ export function FilterControl() { > { TankFilters.mutate((draft) => { - draft.testing = "include"; - }); - }} - > - - - { - TankFilters.mutate((draft) => { - draft.testing = "exclude"; + draft.showNonTesting = !draft.showNonTesting; }); }} > @@ -607,15 +577,16 @@ export function FilterControl() { style={{ width: "1em", height: "1em", color: "currentColor" }} /> + { TankFilters.mutate((draft) => { - draft.testing = "only"; + draft.showTesting = !draft.showTesting; }); }} > diff --git a/packages/website/src/components/TankSearch/index.tsx b/packages/website/src/components/TankSearch/index.tsx index a2a819ac1..581833c1c 100644 --- a/packages/website/src/components/TankSearch/index.tsx +++ b/packages/website/src/components/TankSearch/index.tsx @@ -487,7 +487,7 @@ export const TankSearch = memo( )} - {tankFilters.testing === "only" && ( + {tankFilters.showTesting && !tankFilters.showNonTesting && ( diff --git a/packages/website/src/core/blitzkit/filterTank.ts b/packages/website/src/core/blitzkit/filterTank.ts index 69ccf6660..029505948 100644 --- a/packages/website/src/core/blitzkit/filterTank.ts +++ b/packages/website/src/core/blitzkit/filterTank.ts @@ -10,16 +10,14 @@ export async function filterTank( owned: number[] = [] ) { return ( - (filters.ownership === "all" || - (filters.ownership === "owned" && owned.includes(tank.id)) || - (filters.ownership === "unowned" && !owned.includes(tank.id))) && + ((filters.showOwned && owned.includes(tank.id)) || + (filters.showUnowned && !owned.includes(tank.id))) && (filters.tiers.length === 0 || filters.tiers.includes(tank.tier)) && (filters.nations.length === 0 || filters.nations.includes(tank.nation)) && (filters.classes.length === 0 || filters.classes.includes(tank.class)) && (filters.types.length === 0 || filters.types.includes(tank.type)) && - (filters.testing === "include" || - (filters.testing === "only" && tank.testing) || - (filters.testing === "exclude" && !tank.testing)) && + ((filters.showTesting && tank.testing) || + (filters.showNonTesting && !tank.testing)) && (filters.gunType.length === 0 || (filters.gunType.includes("regular") && tank.turrets.some((turret) => diff --git a/packages/website/src/pages/[...locale]/playlist/_index.tsx b/packages/website/src/pages/[...locale]/playlist/_index.tsx index 727262d7b..0fe0c6f44 100644 --- a/packages/website/src/pages/[...locale]/playlist/_index.tsx +++ b/packages/website/src/pages/[...locale]/playlist/_index.tsx @@ -17,9 +17,7 @@ export function Page({ }: Props & MaybeSkeletonComponentProps) { const generated = Playlist.use((state) => state.list !== undefined); - if (App.state.logins.wargaming && TankFilters.state.ownership !== "owned") { - TankFilters.state.ownership = "owned"; - } + if (App.state.logins.wargaming) TankFilters.state.showUnowned = false; return ( diff --git a/packages/website/src/stores/tankFilters.ts b/packages/website/src/stores/tankFilters.ts index 5cd11c2e3..68999b562 100644 --- a/packages/website/src/stores/tankFilters.ts +++ b/packages/website/src/stores/tankFilters.ts @@ -17,12 +17,15 @@ export interface TankFilters { nations: string[]; classes: TankClass[]; types: TankType[]; - testing: "include" | "exclude" | "only"; search: string | null; searching: boolean; gunType: CaseType[]; shells: [ShellType | null, ShellType | null, ShellType | null]; - ownership: "all" | "owned" | "unowned"; + + showTesting: boolean; + showNonTesting: boolean; + showOwned: boolean; + showUnowned: boolean; } export const TankFilters = new Varuna({ @@ -30,10 +33,13 @@ export const TankFilters = new Varuna({ nations: [], classes: [], types: [], - testing: "include", search: null, searching: false, gunType: [], shells: [null, null, null], - ownership: "all", + + showTesting: true, + showNonTesting: true, + showOwned: true, + showUnowned: true, });