Skip to content

Commit

Permalink
Remove request chunking
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed Oct 16, 2024
1 parent 960b1ea commit 31954ba
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/plugins/sessionPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,22 @@ function unsubscribeFromPlayerUpdates(instance) {
}

async function updatePlaylist(instance, queue) {
instance.playlist = [];
const max = 100;
const apiClient = getCurrentApiClient(instance);

const fetch = async (newQueue) => {
const options = {
ids: newQueue.map(i => i.Id ),
serverId: apiClient.serverId()
};

const result = await playbackManager.getItemsForPlayback(options.serverId, {
Ids: options.ids.join(',')
});

const items = await playbackManager.translateItemsForPlayback(result.Items, options);

for (let i = 0, length = items.length; i < length; i++) {
items[i].PlaylistItemId = newQueue[i].PlaylistItemId;
}
return items;
const options = {
ids: queue.map(i => i.Id),
serverId: getCurrentApiClient(instance).serverId()
};

const n = Math.floor(queue.length / max) + 1;
const result = await playbackManager.getItemsForPlayback(options.serverId, {
Ids: options.ids.join(',')
});

const items = await playbackManager.translateItemsForPlayback(result.Items, options);

for (let i = 0; i < n; i++) {
instance.playlist.push(...await fetch(queue.slice(max * i, max * (i + 1))));
for (let i = 0; i < items.length; i++) {
items[i].PlaylistItemId = queue[i].PlaylistItemId;
}

instance.playlist = items;
}

function compareQueues(q1, q2) {
Expand Down

0 comments on commit 31954ba

Please sign in to comment.