Repository navigation
Conversation
Use the market listing link on badge cards to recover the canonical English market hash name before requesting orderbook prices. Keep the visible localized name for badge completion display and fall back to it when Steam does not provide a listing link. Fixes IsThereAnyDeal#2393
|
Thanks for taking a look at this. However, I tested the PR, and it doesn't seem to work at all. The following condition seems to always evaluate to if (!href) {
return `${appid}-${cardName}`;
}Anyway, I don't think relying on the
Another possibility would be to retrieve the original card names from the URLs used by the Alternatively, perhaps the original card names could be retrieved using Steam's
The |
|
Thanks for testing it, and sorry for the noise. You're right. My test built the card markup by hand with a listing link inside I'll rework this to take the market hash names from |
The market only knows the English card names, so on a badge page in another language the orderbook was asked for the localized name and answered success:false. The listing link the first version read is only rendered for unowned cards on the owner's own page, so it did nothing on the page from the report. Fetch the English version of the badge page once when the first price is requested and match the cards by position instead. Steam also wraps the orderbook payload in an outer data object now, so read it through parseOrderBookResponse like the inventory does. Fixes IsThereAnyDeal#2392 Fixes IsThereAnyDeal#2393
|
Pushed a rework and dropped the listing link approach. I tried The orderbook response also needed the Checked against your badge page from a runner: German and English both list 8 cards in the same order, Zerstörung, Das Labor and Untergrund line up with Destruction, The Lab and Underground, and the orderbook for |
|
Thanks for the rework! I tested the latest version on badge pages in Polish, English, and German, and the original issue seems to be fixed. The card names are now resolved correctly, and the prices load as expected in all three languages. I also confirmed that no additional request for the English version is made when viewing an English badge page (that's nice). I did notice one unrelated issue while testing on another user's badge page, though. When clicking For example, you can reproduce this on This seems to be caused by the existing I tried adding a if (isUnowned && badgeCompletion) {
costMap.set(cardName, price);
badgeCompletion.update(costMap);
}And that seems to prevent the error in my tests. This appears to be an issue in the existing code rather than something introduced by your PR, but I thought I'd mention it anyway. Thanks again for working on this! |
BadgeCompletion is only created on the user's own badge page, but the price callback updated it for every unowned card, so on another user's page the loaded price ended in "An error occurred". It stayed hidden while every card price came back as N/A.
|
Thanks for testing it in three languages. I added your |
Fixes #2393
Fixes #2392
Summary
On a badge page in another language the card names are localized, but the market only knows the English names, so the orderbook was asked for
620-Zerstörungand answeredsuccess: false(#2393). The first version of this PR read the names from the market listing links on the cards. Those links only exist for unowned cards on a signed-in user's own badge page, so it did nothing on the page from the report.The English names are now taken from the English version of the same badge page. When the first price is requested on a page whose language is not English, the page is fetched once more with
l=englishand the cards are matched by position, since both pages list them in the same order. If the counts differ, the visible names are kept. Pages already in English fetch nothing extra. The "Lowest price" link uses the same name, so it opens the right listing./market/search/render/would also give the names, but it answers 10 cards per request and every request from a CI runner was rate limited (HTTP 429).The orderbook response is now wrapped in an outer
dataobject (#2392), which left every card at N/A whichever name was used, so the card loader goes throughparseOrderBookResponsefrom #2367 like the inventory does. Without that the name fix cannot be seen.Test plan
test/card-market-name.test.mjs(npm test, also run in the build workflow): reading the names from the card markup in German and English, matching by position with the count mismatch fallback, and thel=englishURL keepingborder=1.Zerstörung,Das LaborandUntergrundline up withDestruction,The LabandUnderground; the orderbook for620-Destructionanswers{"data":{"success":true,...}}with a price and620-Zerstörunganswerssuccess: false.npm run checkand production builds for Firefox, Chrome and Edge.Not checked: that
l=englishleaves the account language alone for a signed-in user. As far as I know the query parameter only applies to that request, and the steps in the issue switch languages the same way.