Speed up client home by loading shelves in parallel.
Shelf item queries no longer run one-by-one; favorites load alongside them. Response shape and shelf order stay the same. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b5fc140e9f
commit
7869cd6661
1 changed files with 14 additions and 3 deletions
|
|
@ -692,8 +692,19 @@ export class ViewerService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const shelf of ordered) {
|
// Plank-items parallel laden (volgorde van `ordered` blijft behouden via Promise.all-index).
|
||||||
|
// Favorites hangt niet van planken af → tegelijk ophalen i.p.v. erna.
|
||||||
|
const [shelfPayloads, favorites] = await Promise.all([
|
||||||
|
Promise.all(
|
||||||
|
ordered.map(async (shelf) => {
|
||||||
const items = await this.shelfItems(shelf.id, shelf.kind, 48, kidsMode);
|
const items = await this.shelfItems(shelf.id, shelf.kind, 48, kidsMode);
|
||||||
|
return { shelf, items };
|
||||||
|
})
|
||||||
|
),
|
||||||
|
this.listFavorites(profileId, kidsMode),
|
||||||
|
]);
|
||||||
|
|
||||||
|
for (const { shelf, items } of shelfPayloads) {
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
const homepageLabel = shelf.homepageName?.trim();
|
const homepageLabel = shelf.homepageName?.trim();
|
||||||
rows.push({
|
rows.push({
|
||||||
|
|
@ -711,7 +722,7 @@ export class ViewerService {
|
||||||
continueWatching: continueItems,
|
continueWatching: continueItems,
|
||||||
spotlight,
|
spotlight,
|
||||||
shelves: rows,
|
shelves: rows,
|
||||||
favorites: await this.listFavorites(profileId, kidsMode),
|
favorites,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue