Merge pull request #280 from Hitjack007/filter-defaults

This commit is contained in:
TrèsAbhi authored and GitHub committed 2026-10-04 14:08:54 -05:00
commit 91f2b7afd0
4 files changed
+16 -7

No files matched your search

@@ -789,6 +789,7 @@ function OwnershipFilterInternal(props: FlexProps) {
onClick={() => {
TankFilters.mutate((draft) => {
draft.showOwned = !draft.showOwned;
if (draft.showOwned) draft.showUnowned = false;
});
}}
>
@@ -808,6 +809,7 @@ function OwnershipFilterInternal(props: FlexProps) {
onClick={() => {
TankFilters.mutate((draft) => {
draft.showUnowned = !draft.showUnowned;
if (draft.showUnowned) draft.showOwned = false;
});
}}
>
@@ -834,6 +836,7 @@ function TestFilter() {
onClick={() => {
TankFilters.mutate((draft) => {
draft.showNonTesting = !draft.showNonTesting;
if (draft.showNonTesting) draft.showTesting = false;
});
}}
>
@@ -854,6 +857,7 @@ function TestFilter() {
onClick={() => {
TankFilters.mutate((draft) => {
draft.showTesting = !draft.showTesting;
if (draft.showTesting) draft.showNonTesting = false;
});
}}
>
@@ -16,13 +16,15 @@ export async function filterTank(
owned: number[] = [],
) {
return (
((filters.showOwned && owned.includes(tank.id)) ||
((!filters.showOwned && !filters.showUnowned) ||
(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.showTesting && tank.testing) ||
((!filters.showTesting && !filters.showNonTesting) ||
(filters.showTesting && tank.testing) ||
(filters.showNonTesting && !tank.testing)) &&
(filters.gunType.length === 0 ||
(filters.gunType.includes("regular") &&
@@ -17,7 +17,10 @@ export function Page({
}: Props & MaybeSkeletonComponentProps) {
const generated = Playlist.use((state) => state.list !== undefined);
if (App.state.logins.wargaming) TankFilters.state.showUnowned = false;
if (App.state.logins.wargaming) {
TankFilters.state.showOwned = true;
TankFilters.state.showUnowned = false;
}
return (
<LocaleProvider locale={locale}>
+4 -4
View File
@@ -46,8 +46,8 @@ export const TankFilters = new Varuna<TankFilters>({
abilities: [],
powers: [],
showTesting: true,
showNonTesting: true,
showOwned: true,
showUnowned: true,
showTesting: false,
showNonTesting: false,
showOwned: false,
showUnowned: false,
});