Skip to content

Commit

Permalink
update cube import for CubeCobra API change (#1710)
Browse files Browse the repository at this point in the history
CubeCobra's JSON response (since 5.9?) was changed; the 'cards' object
used to hold an array of cards, now it has sub-objects 'mainboard' and
'maybeboard' with the card arrays.

Co-authored-by: mildmongrel <mildmongrel+github@gmail.com>
  • Loading branch information
mildmongrel and mildmongrel committed Jun 4, 2023
1 parent b662361 commit b77abde
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/src/lobby/CubeList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ const CubeCobra = () => {
try {
const {data: {cards}} = await axios.get(`https://cubecobra.com/cube/api/cubeJSON/${cubeId}`);

setCubeImportMessage(`Fetching card versions... (0/${cards.length})`);
setCubeImportMessage(`Fetching card versions... (0/${cards.mainboard.length})`);

let totalCards = 0;
const cardNames = (await Promise.all(
_.chunk(cards, 75)
_.chunk(cards.mainboard, 75)
.map(async (chunk) => {
const {data} = await axios.post(
'https://api.scryfall.com/cards/collection',
{identifiers: chunk.map((card) => ({id: card.cardID}))});

totalCards += data.data.length;
setCubeImportMessage(`Fetching card versions... (${totalCards}/${cards.length})`);
setCubeImportMessage(`Fetching card versions... (${totalCards}/${cards.mainboard.length})`);

return data.data.map((card) => {
const name = card.card_faces ? card.card_faces[0].name : card.name;
Expand Down

0 comments on commit b77abde

Please sign in to comment.