Skip to content

Commit c38f348

Browse files
committed
add sticker/keychain names
1 parent 12b2bd0 commit c38f348

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

src/lib/bridge/handlers/fetch_inspect_info.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export const FetchInspectInfo = new SimpleHandler<FetchInspectInfoRequest, Fetch
6969
let weaponType: string | undefined;
7070
let itemName: string | undefined;
7171
let rarityName: string | undefined;
72+
let stickers: Sticker[] = [];
73+
let keychains: Keychain[] = [];
7274

7375
try {
7476
const schema = await gSchemaFetcher.getSchema();
@@ -83,23 +85,35 @@ export const FetchInspectInfo = new SimpleHandler<FetchInspectInfoRequest, Fetch
8385
min = paint.min;
8486
max = paint.max;
8587
}
86-
} catch (error) {
87-
console.error('Failed to fetch schema item metadata:', error);
88-
}
8988

90-
return {
91-
iteminfo: {
92-
stickers: decoded.stickers.map((sticker) => ({
89+
stickers = decoded.stickers.map((sticker) => {
90+
const schemaSticker = schema.stickers[sticker.stickerId?.toString() ?? ''];
91+
return {
9392
slot: sticker.slot ?? 0,
9493
stickerId: sticker.stickerId ?? 0,
9594
wear: sticker.wear,
96-
})),
97-
keychains: decoded.keychains.map((keychain) => ({
95+
name: schemaSticker?.market_hash_name,
96+
};
97+
});
98+
99+
keychains = decoded.keychains.map((keychain) => {
100+
const schemaKeychain = schema.keychains[keychain.stickerId?.toString() ?? ''];
101+
return {
98102
slot: keychain.slot ?? 0,
99103
stickerId: keychain.stickerId ?? 0,
100104
wear: keychain.wear,
101105
pattern: keychain.pattern ?? 0,
102-
})),
106+
name: schemaKeychain?.market_hash_name,
107+
};
108+
});
109+
} catch (error) {
110+
console.error('Failed to fetch schema item metadata:', error);
111+
}
112+
113+
return {
114+
iteminfo: {
115+
stickers,
116+
keychains,
103117
itemid: decoded.itemid?.toString() ?? '',
104118
defindex,
105119
paintindex,
@@ -120,9 +134,9 @@ export const FetchInspectInfo = new SimpleHandler<FetchInspectInfoRequest, Fetch
120134
}
121135
);
122136

123-
function getSchemaPaint(weapon: ItemSchema.RawWeapon | undefined, paintIndex: number) {
137+
function getSchemaPaint(weapon: ItemSchema.RawWeapon | undefined, paintIndex: number): ItemSchema.RawPaint | undefined {
124138
if (!weapon) {
125-
return;
139+
return undefined;
126140
}
127141

128142
if (weapon.paints[paintIndex] !== undefined) {

src/lib/components/market/sort_listings.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ export class SortListings extends FloatElement {
122122
// Catch error to prevent one failure from stopping the Promise.all() later
123123
try {
124124
const link = getMarketInspectLink(listingId);
125+
const info = await gFloatFetcher.fetch({link: link!});
125126
const listingInfo = g_rgListingInfo[listingId];
126127
const asset = g_rgAssets[AppId.CSGO][ContextId.PRIMARY][listingInfo.asset.id];
127-
const info = await gFloatFetcher.fetch({
128-
link: link!,
129-
});
130128
return {
131129
failed: false,
132130
info,

0 commit comments

Comments
 (0)