-
Notifications
You must be signed in to change notification settings - Fork 28
Fix Tidal album artist duplication #182
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,10 +349,20 @@ export class TidalV2ReleaseLookup extends ReleaseApiLookup<TidalProvider, Single | |
| resourceType: 'artists' | 'artworks' | 'providers', | ||
| ): T[] { | ||
| const targetRels = rawRelease.data.relationships[relationship]; | ||
| const relatedIds = new Set(targetRels?.data?.map((item) => item.id)); | ||
| if (!targetRels) { | ||
| return []; | ||
| } | ||
| const relatedIds = new Set(targetRels.data?.map((item) => item.id)); | ||
|
|
||
| return rawRelease.included | ||
| .filter((resource) => resource.type === resourceType && relatedIds.has(resource.id)) as T[]; | ||
| const items = new Map<string, T>(); | ||
| rawRelease.included.forEach((resource) => { | ||
| if (resource.type === resourceType && relatedIds.has(resource.id)) { | ||
| items.set(resource.id, resource as T); | ||
| } | ||
| }); | ||
| // Rely on the target relationship to get the correct number and order of related | ||
| // items. Consider the case that an item was not actually returned in the includes. | ||
| return targetRels.data.map((rel) => items.get(rel.id) || { id: rel.id } as T); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we currently need the fallback value at all? As far as I can see it doesn't matter whether we return the incomplete object or So far I've only seen missing resources for track artists, which has a completely separate implementation in
In the long term we probably want to properly type the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly because of the concerns that also release artists might be missing. I haven't seen such a case, but I think it could happen. But yes, we could refactor this to a similar system then as used for tracks. Actually the way tracks handle this was added later, and it was done separated as the existing
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added #185 to track this. |
||
| } | ||
|
|
||
| private constructReleaseUrlFromRelease(release: ReleaseResource): URL { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.