- toLoad.push(userCardInfo);
- return userCardInfo;
- });
- const loadMax = 50;
- while (toLoad.length > 0) {
- const thisBatch = toLoad.splice(0, loadMax);
- const promise = ajax("/user-cards.json", {
- data: { user_ids: thisBatch.map((uc) => uc.user.id).join(",") },
- });
- thisBatch.forEach((uc) => {
- // Each user card expects its own promise
- // Rather than making a separate AJAX request for each
- // We re-use the `user-cards.json` promise, and manipulate the data
- const convertedPromise = promise.then((data) => {
- // Find the correct user from users, and put it in the user attribute
- // Use Object.assign to avoid contaminating the source object
- return Object.assign({}, data, {