Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.7.6 #80

Merged
merged 2 commits into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions src/common/yt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,37 +156,44 @@ export const ytService = {
url.pathname = urlResolverFunction.pathname
if (urlResolverFunction.paramArraySeperator === SingleValueAtATime)
{
for (const descriptor of descriptorsGroup)
{
await Promise.all(descriptorsGroup.map(async (descriptor) => {
switch (null)
{
default:
if (!descriptor.id) break
url.searchParams.set(urlResolverFunction.paramName, descriptor.id)

const apiResponse = await fetch(url.toString(), { cache: 'force-cache' });
if (!apiResponse.ok) break
const value = followResponsePath<string>(await apiResponse.json(), urlResolverFunction.responsePath)
if (value) results[descriptor.index] = value
}
progressCount++
if (!descriptor.id) continue
url.searchParams.set(urlResolverFunction.paramName, descriptor.id)

const apiResponse = await fetch(url.toString(), { cache: 'force-cache' });
if (!apiResponse.ok) continue
const value = followResponsePath<string>(await apiResponse.json(), urlResolverFunction.responsePath)
if (value) results[descriptor.index] = value
if (progressCallback) progressCallback(progressCount / descriptorsWithIndex.length)
}
}))
}
else
{

switch (null)
{
default:
url.searchParams
.set(urlResolverFunction.paramName, descriptorsGroup
.map((descriptor) => descriptor.id)
.filter((descriptorId) => descriptorId)
.join(urlResolverFunction.paramArraySeperator)
)
const apiResponse = await fetch(url.toString(), { cache: 'force-cache' });
if (!apiResponse.ok) break
const values = followResponsePath<string[]>(await apiResponse.json(), urlResolverFunction.responsePath)
values.forEach((value, index) => {
const descriptorIndex = descriptorsGroup[index].index
if (value) (results[descriptorIndex] = value)
})
}
progressCount += descriptorsGroup.length
url.searchParams
.set(urlResolverFunction.paramName, descriptorsGroup
.map((descriptor) => descriptor.id)
.filter((descriptorId) => descriptorId)
.join(urlResolverFunction.paramArraySeperator)
)

const apiResponse = await fetch(url.toString(), { cache: 'force-cache' });
if (!apiResponse.ok) return
const values = followResponsePath<string[]>(await apiResponse.json(), urlResolverFunction.responsePath)
values.forEach((value, index) => {
const descriptorIndex = descriptorsGroup[index].index
if (value) (results[descriptorIndex] = value)
if (progressCallback) progressCallback(progressCount / descriptorsWithIndex.length)
})
if (progressCallback) progressCallback(progressCount / descriptorsWithIndex.length)
}
}

Expand Down