mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: optimize awaitables
This commit is contained in:
1 parent
80fca2e53a
commit
74e85f82f1
54 files changed
+259
-190
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
fetchModelDefinitions,
|
||||
normalizeBoundingBox,
|
||||
resolveDpm,
|
||||
unionBoundingBox,
|
||||
@@ -7,6 +6,7 @@ import {
|
||||
} from '@blitzkit/core';
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { useMemo } from 'react';
|
||||
import { awaitableModelDefinitions } from '../../../core/awaitables/modelDefinitions';
|
||||
import { resolveReload } from '../../../core/blitzkit/resolveReload';
|
||||
import { $tankopediaSort } from '../../../stores/tankopediaSort';
|
||||
import { TankCard } from '../../TankCard';
|
||||
@@ -16,7 +16,7 @@ interface TankSearchCardProps {
|
||||
onSelect?: (tank: TankDefinition) => void;
|
||||
}
|
||||
|
||||
const modelDefinitions = await fetchModelDefinitions();
|
||||
const modelDefinitions = await awaitableModelDefinitions;
|
||||
|
||||
export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
||||
const tankopediaSort = useStore($tankopediaSort);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
asset,
|
||||
fetchGameDefinitions,
|
||||
TANK_CLASSES,
|
||||
TankType,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
@@ -9,6 +8,7 @@ import { useStore } from '@nanostores/react';
|
||||
import { ReloadIcon } from '@radix-ui/react-icons';
|
||||
import { Box, Flex, IconButton, Text } from '@radix-ui/themes';
|
||||
import { times } from 'lodash-es';
|
||||
import { awaitableGameDefinitions } from '../../../core/awaitables/gameDefinitions';
|
||||
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
||||
import {
|
||||
$tankopediaSort,
|
||||
@@ -27,7 +27,7 @@ interface FilterControlProps {
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
const gameDefinitions = await fetchGameDefinitions();
|
||||
const gameDefinitions = await awaitableGameDefinitions;
|
||||
|
||||
export function FilterControl({ compact }: FilterControlProps) {
|
||||
const tankFilters = useStore($tankFilters);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { fetchTankDefinitions } from '@blitzkit/core';
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { Flex, Separator, Text } from '@radix-ui/themes';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { useMemo } from 'react';
|
||||
import { awaitableTankDefinitions } from '../../../core/awaitables/tankDefinitions';
|
||||
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
||||
import { TankopediaPersistent } from '../../../stores/tankopediaPersistent';
|
||||
import { $tankopediaSort } from '../../../stores/tankopediaSort';
|
||||
import { TankCard } from '../../TankCard';
|
||||
import { TankCardWrapper } from './TankCardWrapper';
|
||||
|
||||
const tankDefinitions = await fetchTankDefinitions();
|
||||
const tankDefinitions = await awaitableTankDefinitions;
|
||||
|
||||
export function RecentlyViewed() {
|
||||
const tankopediaPersistentStore = TankopediaPersistent.useStore();
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
fetchGameDefinitions,
|
||||
fetchModelDefinitions,
|
||||
fetchTankDefinitions,
|
||||
fetchTankNames,
|
||||
metaSortTank,
|
||||
normalizeBoundingBox,
|
||||
resolveDpm,
|
||||
@@ -14,6 +10,10 @@ import { Callout, Flex, Link, Text, type FlexProps } from '@radix-ui/themes';
|
||||
import fuzzysort from 'fuzzysort';
|
||||
import { times, uniq } from 'lodash-es';
|
||||
import { memo, useEffect, useMemo, useState } from 'react';
|
||||
import { awaitableGameDefinitions } from '../../core/awaitables/gameDefinitions';
|
||||
import { awaitableModelDefinitions } from '../../core/awaitables/modelDefinitions';
|
||||
import { awaitableTankDefinitions } from '../../core/awaitables/tankDefinitions';
|
||||
import { awaitableTankNames } from '../../core/awaitables/tankNames';
|
||||
import { filterTank } from '../../core/blitzkit/filterTank';
|
||||
import { resolveReload } from '../../core/blitzkit/resolveReload';
|
||||
import { $tankFilters } from '../../stores/tankFilters';
|
||||
@@ -42,10 +42,13 @@ type TankSearchProps = Omit<FlexProps, 'onSelect'> & {
|
||||
const PREVIEW_COUNT = 25;
|
||||
const DEFAULT_LOADED_CARDS = 75;
|
||||
|
||||
const gameDefinitions = await fetchGameDefinitions();
|
||||
const modelDefinitions = await fetchModelDefinitions();
|
||||
const tankDefinitions = await fetchTankDefinitions();
|
||||
const tankNames = await fetchTankNames();
|
||||
const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
|
||||
await Promise.all([
|
||||
awaitableGameDefinitions,
|
||||
awaitableModelDefinitions,
|
||||
awaitableTankDefinitions,
|
||||
awaitableTankNames,
|
||||
]);
|
||||
|
||||
export const TankSearch = memo<TankSearchProps>(
|
||||
({ compact, onSelect, onSelectAll, ...props }) => {
|
||||
|
||||
Reference in new issue
Block a user