mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
Fix: search redirecting early and missing full tank names
**Enter key** - Enter redirected to the previous results' first tank while a search was still buffering, because the key handler captured a stale `searching` value. - Enter on an empty field redirected to the first tank of the unfiltered list (Sheridan). - The handler now reads live filter state and only acts when there is a settled search, matching the quick-link button. **Full names in search** - Search only knew short tank names, so queries like "super pershing" found nothing when the game stores a short form. - Add an optional `name_full` to `TankDefinition`, filled from the game's full name when a short name exists, and index it (plus an accent-stripped copy) in `fetchTankNames` / `SEARCH_KEYS`. - Displayed names are unchanged. Full names become searchable once the definitions are regenerated on the next build.
This commit is contained in:
1 parent
f3e8cdd5e0
commit
6153beced6
5 files changed
+39
-1
No files matched your search
@@ -371,6 +371,9 @@ export abstract class ServerBlitzKitAPI1 extends ServerBlitzKitAPI0 {
|
|||||||
(tank.shortUserString
|
(tank.shortUserString
|
||||||
? this.getString(tank.shortUserString)
|
? this.getString(tank.shortUserString)
|
||||||
: undefined) ?? this.getString(tank.userString),
|
: undefined) ?? this.getString(tank.userString),
|
||||||
|
name_full: tank.shortUserString
|
||||||
|
? this.getString(tank.userString)
|
||||||
|
: undefined,
|
||||||
slug,
|
slug,
|
||||||
nation,
|
nation,
|
||||||
type: tankTags.includes("collectible")
|
type: tankTags.includes("collectible")
|
||||||
|
|||||||
@@ -18,11 +18,22 @@ export async function fetchTankNames(api: BlitzKitAPI) {
|
|||||||
searchableNameDeburr.locales[key] = deburr(value);
|
searchableNameDeburr.locales[key] = deburr(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const searchableNameFull: I18nString = {
|
||||||
|
locales: { ...tank.name_full?.locales },
|
||||||
|
};
|
||||||
|
const searchableNameFullDeburr: I18nString = { locales: {} };
|
||||||
|
|
||||||
|
Object.entries(searchableNameFull.locales).forEach(([key, value]) => {
|
||||||
|
searchableNameFullDeburr.locales[key] = deburr(value);
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: tank.id,
|
id: tank.id,
|
||||||
name: tank.name,
|
name: tank.name,
|
||||||
searchableName: tank.name,
|
searchableName: tank.name,
|
||||||
searchableNameDeburr,
|
searchableNameDeburr,
|
||||||
|
searchableNameFull,
|
||||||
|
searchableNameFullDeburr,
|
||||||
camouflages: tank.camouflages
|
camouflages: tank.camouflages
|
||||||
?.map((id) =>
|
?.map((id) =>
|
||||||
locales.supported.map(
|
locales.supported.map(
|
||||||
@@ -45,6 +56,8 @@ export const SEARCH_KEYS = [
|
|||||||
.map(({ locale }) => [
|
.map(({ locale }) => [
|
||||||
`searchableName.locales.${locale}`,
|
`searchableName.locales.${locale}`,
|
||||||
`searchableNameDeburr.locales.${locale}`,
|
`searchableNameDeburr.locales.${locale}`,
|
||||||
|
`searchableNameFull.locales.${locale}`,
|
||||||
|
`searchableNameFullDeburr.locales.${locale}`,
|
||||||
])
|
])
|
||||||
.flat(),
|
.flat(),
|
||||||
"camouflages",
|
"camouflages",
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ message TankDefinition {
|
|||||||
required uint32 weight = 31;
|
required uint32 weight = 31;
|
||||||
required string dev_name = 32;
|
required string dev_name = 32;
|
||||||
optional Equalizer equalizer = 33;
|
optional Equalizer equalizer = 33;
|
||||||
|
optional I18nString name_full = 34;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Equalizer {
|
message Equalizer {
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ export interface TankDefinition {
|
|||||||
weight: number;
|
weight: number;
|
||||||
dev_name: string;
|
dev_name: string;
|
||||||
equalizer?: Equalizer | undefined;
|
equalizer?: Equalizer | undefined;
|
||||||
|
name_full?: I18nString | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TankDefinition_RolesEntry {
|
export interface TankDefinition_RolesEntry {
|
||||||
@@ -651,6 +652,7 @@ function createBaseTankDefinition(): TankDefinition {
|
|||||||
weight: 0,
|
weight: 0,
|
||||||
dev_name: "",
|
dev_name: "",
|
||||||
equalizer: undefined,
|
equalizer: undefined,
|
||||||
|
name_full: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,6 +754,9 @@ export const TankDefinition: MessageFns<TankDefinition> = {
|
|||||||
if (message.equalizer !== undefined) {
|
if (message.equalizer !== undefined) {
|
||||||
Equalizer.encode(message.equalizer, writer.uint32(266).fork()).join();
|
Equalizer.encode(message.equalizer, writer.uint32(266).fork()).join();
|
||||||
}
|
}
|
||||||
|
if (message.name_full !== undefined) {
|
||||||
|
I18nString.encode(message.name_full, writer.uint32(274).fork()).join();
|
||||||
|
}
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1051,6 +1056,14 @@ export const TankDefinition: MessageFns<TankDefinition> = {
|
|||||||
message.equalizer = Equalizer.decode(reader, reader.uint32());
|
message.equalizer = Equalizer.decode(reader, reader.uint32());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case 34: {
|
||||||
|
if (tag !== 274) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.name_full = I18nString.decode(reader, reader.uint32());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((tag & 7) === 4 || tag === 0) {
|
if ((tag & 7) === 4 || tag === 0) {
|
||||||
break;
|
break;
|
||||||
@@ -1111,6 +1124,7 @@ export const TankDefinition: MessageFns<TankDefinition> = {
|
|||||||
weight: isSet(object.weight) ? globalThis.Number(object.weight) : 0,
|
weight: isSet(object.weight) ? globalThis.Number(object.weight) : 0,
|
||||||
dev_name: isSet(object.dev_name) ? globalThis.String(object.dev_name) : "",
|
dev_name: isSet(object.dev_name) ? globalThis.String(object.dev_name) : "",
|
||||||
equalizer: isSet(object.equalizer) ? Equalizer.fromJSON(object.equalizer) : undefined,
|
equalizer: isSet(object.equalizer) ? Equalizer.fromJSON(object.equalizer) : undefined,
|
||||||
|
name_full: isSet(object.name_full) ? I18nString.fromJSON(object.name_full) : undefined,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1218,6 +1232,9 @@ export const TankDefinition: MessageFns<TankDefinition> = {
|
|||||||
if (message.equalizer !== undefined) {
|
if (message.equalizer !== undefined) {
|
||||||
obj.equalizer = Equalizer.toJSON(message.equalizer);
|
obj.equalizer = Equalizer.toJSON(message.equalizer);
|
||||||
}
|
}
|
||||||
|
if (message.name_full !== undefined) {
|
||||||
|
obj.name_full = I18nString.toJSON(message.name_full);
|
||||||
|
}
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1271,6 +1288,9 @@ export const TankDefinition: MessageFns<TankDefinition> = {
|
|||||||
message.equalizer = (object.equalizer !== undefined && object.equalizer !== null)
|
message.equalizer = (object.equalizer !== undefined && object.equalizer !== null)
|
||||||
? Equalizer.fromPartial(object.equalizer)
|
? Equalizer.fromPartial(object.equalizer)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
message.name_full = (object.name_full !== undefined && object.name_full !== null)
|
||||||
|
? I18nString.fromPartial(object.name_full)
|
||||||
|
: undefined;
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ export function SearchBar({ topResult, skeleton, onSelect }: SearchBarProps) {
|
|||||||
}, [searching]);
|
}, [searching]);
|
||||||
const handleKeyDown = useCallback<KeyboardEventHandler>(
|
const handleKeyDown = useCallback<KeyboardEventHandler>(
|
||||||
(event) => {
|
(event) => {
|
||||||
if (event.key !== "Enter" || !topResult || searching) return;
|
if (event.key !== "Enter" || !topResult) return;
|
||||||
|
if (!TankFilters.state.search || TankFilters.state.searching) return;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user