mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
revert tank exclusion
This commit is contained in:
1 parent
aa6268a86b
commit
e19d0d5895
3 files changed
+4
-27
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { PlusIcon, TrashIcon } from "@radix-ui/react-icons";
|
||||
import { Button, Dialog, Flex, SegmentedControl } from "@radix-ui/themes";
|
||||
import { useMemo } from "react";
|
||||
import { api } from "../../core/blitzkit/api";
|
||||
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
@@ -23,11 +22,6 @@ export function Controls({
|
||||
onAddTankDialogOpenChange,
|
||||
}: ControlsProps) {
|
||||
const deltaMode = ComparePersistent.use((state) => state.deltaMode);
|
||||
const members = CompareEphemeral.use((state) => state.members);
|
||||
const memberIds = useMemo(
|
||||
() => members.map((member) => member.tank.id),
|
||||
[members],
|
||||
);
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
@@ -59,7 +53,6 @@ export function Controls({
|
||||
>
|
||||
<TankSearch
|
||||
compact
|
||||
exclude={memberIds}
|
||||
onSelect={(tank) => {
|
||||
CompareEphemeral.mutate((draft) => {
|
||||
draft.members.push(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ExternalLinkIcon, LoopIcon, TrashIcon } from "@radix-ui/react-icons";
|
||||
import { Dialog, Flex, IconButton } from "@radix-ui/themes";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { api } from "../../core/blitzkit/api";
|
||||
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
@@ -18,14 +18,6 @@ const provisionDefinitions = await api.provisionDefinitions();
|
||||
export function TankControl({ index, slug }: TankControlProps) {
|
||||
const { locale, strings } = useLocale();
|
||||
const [switchTankDialogOpen, setSwitchTankDialogOpen] = useState(false);
|
||||
const members = CompareEphemeral.use((state) => state.members);
|
||||
const otherMemberIds = useMemo(
|
||||
() =>
|
||||
members
|
||||
.filter((_, memberIndex) => memberIndex !== index)
|
||||
.map((member) => member.tank.id),
|
||||
[members, index],
|
||||
);
|
||||
|
||||
return (
|
||||
<Flex gap="3" justify="center" style={{ width: "100%" }}>
|
||||
@@ -65,7 +57,6 @@ export function TankControl({ index, slug }: TankControlProps) {
|
||||
>
|
||||
<TankSearch
|
||||
compact
|
||||
exclude={otherMemberIds}
|
||||
onSelect={(tank) => {
|
||||
CompareEphemeral.mutate((draft) => {
|
||||
draft.members[index] = tankToCompareMember(
|
||||
|
||||
@@ -38,7 +38,6 @@ export type TankSearchProps = MaybeSkeletonComponentProps &
|
||||
compact?: boolean;
|
||||
onSelect?: (tank: TankDefinition) => void;
|
||||
onSelectAll?: (tanks: TankDefinition[]) => void;
|
||||
exclude?: number[];
|
||||
};
|
||||
|
||||
const PREVIEW_COUNT = 20;
|
||||
@@ -53,14 +52,14 @@ const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
|
||||
]);
|
||||
|
||||
export const TankSearch = memo<TankSearchProps>(
|
||||
({ compact, onSelect, onSelectAll, exclude, skeleton, ...props }) => {
|
||||
({ compact, onSelect, onSelectAll, skeleton, ...props }) => {
|
||||
const { strings, locale } = useLocale();
|
||||
const wargaming = App.use((state) => state.logins.wargaming);
|
||||
const awaitedTanksDefinitionsArray = Object.values(tankDefinitions.tanks);
|
||||
const tankopediaSort = TankSort.use();
|
||||
const tankFilters = TankFilters.use();
|
||||
|
||||
const allFiltered = usePromise(
|
||||
const filtered = usePromise(
|
||||
() => {
|
||||
if (tankFilters.search === null) {
|
||||
return filterTanks(
|
||||
@@ -82,15 +81,9 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
[tankFilters] as any,
|
||||
);
|
||||
const sorted = useMemo(() => {
|
||||
const filtered = allFiltered.filter(
|
||||
(tank) => !exclude?.includes(tank.id),
|
||||
);
|
||||
|
||||
if (tankFilters.search === null) {
|
||||
let sorted: TankDefinition[];
|
||||
|
||||
filtered.sort((a, b) => a.id - b.id);
|
||||
|
||||
switch (tankopediaSort.by) {
|
||||
case "meta.none":
|
||||
sorted = metaSortTank(filtered, gameDefinitions);
|
||||
@@ -424,7 +417,7 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
} else {
|
||||
return filtered;
|
||||
}
|
||||
}, [tankFilters, tankopediaSort, exclude]);
|
||||
}, [tankFilters, tankopediaSort]);
|
||||
|
||||
const [loadedCards, setLoadedCards] = useState(DEFAULT_LOADED_CARDS);
|
||||
const tanks = sorted.slice(0, loadedCards);
|
||||
|
||||
Reference in new issue
Block a user