mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-27 20:49:52 +01:00
fix: search keys
This commit is contained in:
1 parent
ef3006cac1
commit
b9c339daa7
4 files changed
+15
-17
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
import { SEARCH_KEYS } from '@blitzkit/core';
|
||||||
import { literals } from '@blitzkit/i18n';
|
import { literals } from '@blitzkit/i18n';
|
||||||
import { Locale } from 'discord.js';
|
import { Locale } from 'discord.js';
|
||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
@@ -19,10 +20,7 @@ export async function resolveTankId(
|
|||||||
const searchResult = go(
|
const searchResult = go(
|
||||||
`${tank}`,
|
`${tank}`,
|
||||||
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
||||||
{
|
{ keys: SEARCH_KEYS, limit: 1 },
|
||||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (searchResult.length === 0) {
|
if (searchResult.length === 0) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { fetchTankNames, TankType } from '@blitzkit/core';
|
import { fetchTankNames, SEARCH_KEYS, TankType } from '@blitzkit/core';
|
||||||
import { SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
|
||||||
import {
|
import {
|
||||||
ApplicationCommandOptionChoiceData,
|
ApplicationCommandOptionChoiceData,
|
||||||
AutocompleteInteraction,
|
AutocompleteInteraction,
|
||||||
@@ -32,16 +31,7 @@ export async function autocompleteTanks(
|
|||||||
go(
|
go(
|
||||||
focusedOption.value,
|
focusedOption.value,
|
||||||
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
||||||
{
|
{ keys: SEARCH_KEYS, limit: 10 },
|
||||||
keys: [
|
|
||||||
...SUPPORTED_LOCALES.map((locale) => [
|
|
||||||
`searchableName.{locale}`,
|
|
||||||
`searchableNameDeburr.{locale}`,
|
|
||||||
]).flat(),
|
|
||||||
'camouflages',
|
|
||||||
],
|
|
||||||
limit: 10,
|
|
||||||
},
|
|
||||||
).map(async (item) => {
|
).map(async (item) => {
|
||||||
let name = unwrap(item.obj.searchableName);
|
let name = unwrap(item.obj.searchableName);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { deburr } from 'lodash-es';
|
import { deburr } from 'lodash-es';
|
||||||
|
import { SUPPORTED_LOCALES } from '../../../i18n/src/strings';
|
||||||
import { I18nString } from '../protos';
|
import { I18nString } from '../protos';
|
||||||
import { fetchCamouflageDefinitions } from './camouflageDefinitions';
|
import { fetchCamouflageDefinitions } from './camouflageDefinitions';
|
||||||
import { fetchTankDefinitions } from './tankDefinitions';
|
import { fetchTankDefinitions } from './tankDefinitions';
|
||||||
@@ -33,3 +34,11 @@ export async function fetchTankNames() {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const SEARCH_KEYS = [
|
||||||
|
...SUPPORTED_LOCALES.map((locale) => [
|
||||||
|
`searchableName.locales.${locale}`,
|
||||||
|
`searchableNameDeburr.locales.${locale}`,
|
||||||
|
]).flat(),
|
||||||
|
'camouflages',
|
||||||
|
];
|
||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
metaSortTank,
|
metaSortTank,
|
||||||
normalizeBoundingBox,
|
normalizeBoundingBox,
|
||||||
resolveDpm,
|
resolveDpm,
|
||||||
|
SEARCH_KEYS,
|
||||||
unionBoundingBox,
|
unionBoundingBox,
|
||||||
type TankDefinition,
|
type TankDefinition,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
@@ -410,7 +411,7 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
: sorted.reverse();
|
: sorted.reverse();
|
||||||
} else {
|
} else {
|
||||||
const searchedRaw = fuzzysort.go(tankFilters.search, tankNames, {
|
const searchedRaw = fuzzysort.go(tankFilters.search, tankNames, {
|
||||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
keys: SEARCH_KEYS,
|
||||||
});
|
});
|
||||||
const searchedTanks = searchedRaw.map(
|
const searchedTanks = searchedRaw.map(
|
||||||
(result) => tankDefinitions.tanks[result.obj.id],
|
(result) => tankDefinitions.tanks[result.obj.id],
|
||||||
|
|||||||
Reference in new issue
Block a user