From e77dbca954280982d114ca8c44a90fba166396b9 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Thu, 2 Jan 2020 17:13:57 +0100 Subject: [PATCH] Fixed actor data and avatar fetching and display. --- assets/js/actors/actions.js | 7 ++++++- src/media.js | 6 +++++- src/releases.js | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/js/actors/actions.js b/assets/js/actors/actions.js index d2d7ca11..3829c0fc 100644 --- a/assets/js/actors/actions.js +++ b/assets/js/actors/actions.js @@ -9,7 +9,6 @@ import { curateRelease } from '../curate'; function curateActor(actor) { const curatedActor = { ...actor, - avatar: actor.avatar.media, height: actor.heightMetric && { metric: actor.heightMetric, imperial: actor.heightImperial, @@ -30,6 +29,10 @@ function curateActor(actor) { }, }; + if (actor.avatar) { + curatedActor.avatar = actor.avatar.media; + } + if (actor.releases) { curatedActor.releases = actor.releases.map(release => curateRelease(release.release)); } @@ -145,6 +148,8 @@ function initActorActions(store, _router) { id name slug + age + birthdate avatar: actorsAvatarByActorId { media { thumbnail diff --git a/src/media.js b/src/media.js index f1cd271c..1872e1c0 100644 --- a/src/media.js +++ b/src/media.js @@ -211,7 +211,9 @@ async function storePhotos(photos, { .first(); 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; } @@ -219,6 +221,8 @@ async function storePhotos(photos, { 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']), ]); + + return; } await upsert(`${domain}s_${role}s`, photoAssociations, [`${domain}_id`, 'media_id']); diff --git a/src/releases.js b/src/releases.js index c5fcf6d6..1c96f338 100644 --- a/src/releases.js +++ b/src/releases.js @@ -306,7 +306,6 @@ async function storeReleaseAssets(release, releaseId) { targetId: releaseId, subpath, }, identifier), - /* storePhotos(release.covers, { role: 'cover', targetId: releaseId, @@ -316,7 +315,6 @@ async function storeReleaseAssets(release, releaseId) { targetId: releaseId, subpath, }, identifier), - */ ]); } catch (error) { console.log(release.url, error);