Fixed default actor avatar allocation. Fixed lazy loading in actor photos component.

This commit is contained in:
DebaucheryLibrarian
2020-12-27 22:45:38 +01:00
parent f58c07137a
commit ded414577f
6 changed files with 12 additions and 20 deletions

View File

@@ -431,7 +431,7 @@ async function curateProfile(profile, actor) {
async function interpolateProfiles(actorIds) {
const profiles = await knex('actors_profiles')
.select(['actors_profiles.*', 'media.width as avatar_width', 'media.height as avatar_height', 'media.size as avatar_size'])
.select('actors_profiles.*', knex.raw('row_to_json(media) as avatar'))
.whereIn('actor_id', actorIds)
.leftJoin('media', 'actors_profiles.avatar_media_id', 'media.id');
@@ -467,13 +467,6 @@ async function interpolateProfiles(actorIds) {
}].filter(location => Object.keys(location).length > 0),
}), {});
const avatars = actorProfiles.map(profile => profile.avatar_media_id && ({
id: profile.avatar_media_id,
width: profile.avatar_width,
height: profile.avatar_height,
size: profile.avatar_size,
})).filter(Boolean);
const mostFrequentValues = [
'gender',
'ethnicity',
@@ -526,8 +519,9 @@ async function interpolateProfiles(actorIds) {
profile.tattoos = getLongest(valuesByProperty.tattoos);
profile.piercings = getLongest(valuesByProperty.piercings);
profile.avatar_media_id = avatars
.filter(avatar => avatar.entropy > 6)
profile.avatar_media_id = actorProfiles
.map(actorProfile => actorProfile.avatar)
.filter(avatar => avatar && avatar.entropy > 6)
.sort((avatarA, avatarB) => avatarB.height - avatarA.height)[0]?.id || null;
return profile;