Fixed actor data and avatar fetching and display.

This commit is contained in:
ThePendulum 2020-01-02 17:13:57 +01:00
parent 5a6bf2b42f
commit e77dbca954
3 changed files with 11 additions and 4 deletions

View File

@ -9,7 +9,6 @@ import { curateRelease } from '../curate';
function curateActor(actor) { function curateActor(actor) {
const curatedActor = { const curatedActor = {
...actor, ...actor,
avatar: actor.avatar.media,
height: actor.heightMetric && { height: actor.heightMetric && {
metric: actor.heightMetric, metric: actor.heightMetric,
imperial: actor.heightImperial, imperial: actor.heightImperial,
@ -30,6 +29,10 @@ function curateActor(actor) {
}, },
}; };
if (actor.avatar) {
curatedActor.avatar = actor.avatar.media;
}
if (actor.releases) { if (actor.releases) {
curatedActor.releases = actor.releases.map(release => curateRelease(release.release)); curatedActor.releases = actor.releases.map(release => curateRelease(release.release));
} }
@ -145,6 +148,8 @@ function initActorActions(store, _router) {
id id
name name
slug slug
age
birthdate
avatar: actorsAvatarByActorId { avatar: actorsAvatarByActorId {
media { media {
thumbnail thumbnail

View File

@ -211,7 +211,9 @@ async function storePhotos(photos, {
.first(); .first();
if (primaryPhoto) { if (primaryPhoto) {
await upsert(`${domain}s_${role}s`, photoAssociations, [`${domain}_id`, 'media_id']); const remainingAssociations = photoAssociations.filter(association => association.media_id === primaryPhoto.media_id);
await upsert(`${domain}s_${role}s`, remainingAssociations, [`${domain}_id`, 'media_id']);
return; return;
} }
@ -219,6 +221,8 @@ async function storePhotos(photos, {
upsert(`${domain}s_${primaryRole}s`, photoAssociations.slice(0, 1), [`${domain}_id`, 'media_id']), upsert(`${domain}s_${primaryRole}s`, photoAssociations.slice(0, 1), [`${domain}_id`, 'media_id']),
upsert(`${domain}s_${role}s`, photoAssociations.slice(1), [`${domain}_id`, 'media_id']), upsert(`${domain}s_${role}s`, photoAssociations.slice(1), [`${domain}_id`, 'media_id']),
]); ]);
return;
} }
await upsert(`${domain}s_${role}s`, photoAssociations, [`${domain}_id`, 'media_id']); await upsert(`${domain}s_${role}s`, photoAssociations, [`${domain}_id`, 'media_id']);

View File

@ -306,7 +306,6 @@ async function storeReleaseAssets(release, releaseId) {
targetId: releaseId, targetId: releaseId,
subpath, subpath,
}, identifier), }, identifier),
/*
storePhotos(release.covers, { storePhotos(release.covers, {
role: 'cover', role: 'cover',
targetId: releaseId, targetId: releaseId,
@ -316,7 +315,6 @@ async function storeReleaseAssets(release, releaseId) {
targetId: releaseId, targetId: releaseId,
subpath, subpath,
}, identifier), }, identifier),
*/
]); ]);
} catch (error) { } catch (error) {
console.log(release.url, error); console.log(release.url, error);