mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
fix: no fallback on state change
This commit is contained in:
1 parent
059358cff4
commit
ed8a1c2f57
2 files changed
+12
-14
No files matched your search
@@ -47,9 +47,10 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
|
|||||||
const nations = use(NATIONS);
|
const nations = use(NATIONS);
|
||||||
const filters = useTankopediaPersistent((state) => state.filters);
|
const filters = useTankopediaPersistent((state) => state.filters);
|
||||||
const sort = useTankopediaPersistent((state) => state.sort);
|
const sort = useTankopediaPersistent((state) => state.sort);
|
||||||
const awaitedTanks = use(
|
const awaitedTanks = use(tanksDefinitionsArray);
|
||||||
tanksDefinitionsArray.then((tanks) =>
|
const defaultSortedTanks = useMemo(
|
||||||
tanks
|
() =>
|
||||||
|
awaitedTanks
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
treeTypeOrder.indexOf(a.treeType) -
|
treeTypeOrder.indexOf(a.treeType) -
|
||||||
@@ -60,12 +61,12 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
|
|||||||
tankTypeOrder.indexOf(a.type) - tankTypeOrder.indexOf(b.type),
|
tankTypeOrder.indexOf(a.type) - tankTypeOrder.indexOf(b.type),
|
||||||
)
|
)
|
||||||
.sort((a, b) => nations.indexOf(a.nation) - nations.indexOf(b.nation)),
|
.sort((a, b) => nations.indexOf(a.nation) - nations.indexOf(b.nation)),
|
||||||
),
|
[],
|
||||||
);
|
);
|
||||||
const input = useRef<HTMLInputElement>(null);
|
const input = useRef<HTMLInputElement>(null);
|
||||||
const searchableTanks = useMemo(
|
const searchableTanks = useMemo(
|
||||||
() =>
|
() =>
|
||||||
awaitedTanks
|
defaultSortedTanks
|
||||||
.filter(
|
.filter(
|
||||||
(tank) =>
|
(tank) =>
|
||||||
(filters.tiers.length === 0
|
(filters.tiers.length === 0
|
||||||
@@ -134,6 +135,7 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
|
|||||||
<TextField.Slot>
|
<TextField.Slot>
|
||||||
<MagnifyingGlassIcon height="16" width="16" />
|
<MagnifyingGlassIcon height="16" width="16" />
|
||||||
</TextField.Slot>
|
</TextField.Slot>
|
||||||
|
|
||||||
<TextField.Input
|
<TextField.Input
|
||||||
ref={input}
|
ref={input}
|
||||||
placeholder="Search tanks..."
|
placeholder="Search tanks..."
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Text } from '@radix-ui/themes';
|
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { Suspense } from 'react';
|
|
||||||
import PageWrapper from '../../../components/PageWrapper';
|
import PageWrapper from '../../../components/PageWrapper';
|
||||||
import { TankSearch } from './components/TankSearch';
|
import { TankSearch } from './components/TankSearch';
|
||||||
|
|
||||||
@@ -11,13 +9,11 @@ export default function Page() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageWrapper size="wide" color="purple">
|
<PageWrapper size="wide" color="purple">
|
||||||
<Suspense fallback={<Text>Loading...</Text>}>
|
<TankSearch
|
||||||
<TankSearch
|
onSelect={(tank) => {
|
||||||
onSelect={(tank) => {
|
router.push(`./tankopedia/${tank.id}`);
|
||||||
router.push(`./tankopedia/${tank.id}`);
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
|
||||||
</Suspense>
|
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user