Further refactoring. Fixed actor pages and more.

This commit is contained in:
2019-12-31 03:12:52 +01:00
parent 1c43884102
commit 5a6bf2b42f
11 changed files with 206 additions and 137 deletions

View File

@@ -1,9 +1,15 @@
import { graphql, get } from '../api';
import {
releasePosterFragment,
releaseActorsFragment,
releaseTagsFragment,
} from '../fragments';
import { curateRelease } from '../curate';
function curateActor(actor) {
const curatedActor = {
...actor,
avatar: actor.avatar[0],
avatar: actor.avatar.media,
height: actor.heightMetric && {
metric: actor.heightMetric,
imperial: actor.heightImperial,
@@ -24,6 +30,14 @@ function curateActor(actor) {
},
};
if (actor.releases) {
curatedActor.releases = actor.releases.map(release => curateRelease(release.release));
}
if (actor.photos) {
curatedActor.photos = actor.photos.map(photo => photo.media);
}
return curatedActor;
}
@@ -50,15 +64,19 @@ function initActorActions(store, _router) {
hasPiercings
tattoos
piercings
avatar: actorsMediasByTargetId(condition: { role:"avatar" }) {
thumbnail
path
avatar: actorsAvatarByActorId {
media {
thumbnail
path
}
}
photos: actorsMediasByTargetId(condition: { role:"photo" }) {
id
thumbnail
path
index
photos: actorsPhotos {
media {
id
thumbnail
path
index
}
}
birthCity
birthState
@@ -74,7 +92,7 @@ function initActorActions(store, _router) {
name
alias
}
social: actorsSocialsByTargetId {
social: actorsSocials {
id
url
platform
@@ -84,6 +102,29 @@ function initActorActions(store, _router) {
name
slug
}
releases: releasesActors {
release {
id
url
title
date
${releaseActorsFragment}
${releaseTagsFragment}
${releasePosterFragment}
site {
id
name
slug
url
network {
id
name
slug
url
}
}
}
}
}
}
`, {
@@ -104,8 +145,10 @@ function initActorActions(store, _router) {
id
name
slug
avatar: actorsMediasByTargetId(condition: { role:"avatar" }) {
thumbnail
avatar: actorsAvatarByActorId {
media {
thumbnail
}
}
birthCountry: countryByBirthCountryAlpha2 {
alpha2

View File

@@ -12,16 +12,18 @@ function curateActor(actor) {
}
function curateRelease(release) {
console.log(release);
const curatedRelease = {
...release,
actors: release.actors.map(({ actor }) => curateActor(actor)),
actors: release.actors ? release.actors.map(({ actor }) => curateActor(actor)) : [],
poster: release.poster && release.poster.media,
tags: release.tags.map(({ tag }) => tag),
tags: release.tags ? release.tags.map(({ tag }) => tag) : [],
network: release.site.network,
};
if (release.photos) curatedRelease.photos = release.photos.map(({ media }) => media);
if (release.trailer) [curatedRelease.trailer] = release.trailer.media;
if (release.trailer) curatedRelease.trailer = release.trailer.media;
return curatedRelease;
}