fix(plexseries): add guards to protect when roles and genre are missing

This commit is contained in:
Travis Shivers 2020-09-09 21:41:24 -05:00
parent 0023ba9252
commit 780e834fce
No known key found for this signature in database
GPG Key ID: EE4CC2891B8FCD33
1 changed files with 32 additions and 36 deletions

View File

@ -56,7 +56,7 @@
{{ metadata.summary }} {{ metadata.summary }}
</p> </p>
<div> <div v-if="genres.length > 0">
<v-chip <v-chip
v-for="genre in genres" v-for="genre in genres"
:key="genre.tag" :key="genre.tag"
@ -68,35 +68,37 @@
</v-chip> </v-chip>
</div> </div>
<v-subheader class="white--text"> <template v-if="roles.length > 0">
Featuring <v-subheader class="white--text">
</v-subheader> Featuring
</v-subheader>
<v-row> <v-row>
<v-col <v-col
v-for="role in roles" v-for="role in roles"
:key="role.tag" :key="role.tag"
cols="12" cols="12"
md="6" md="6"
lg="4" lg="4"
> >
<v-chip style="border: none; background: none; color: white;"> <v-chip style="border: none; background: none; color: white;">
<v-avatar left> <v-avatar left>
<v-img <v-img
:src="makeHttpsUrl(role.thumb)" :src="makeHttpsUrl(role.thumb)"
/> />
</v-avatar> </v-avatar>
{{ role.tag }} {{ role.tag }}
<div <div
style="opacity: 0.7; font-size: 80%;" style="opacity: 0.7; font-size: 80%;"
class="pa-2" class="pa-2"
> >
{{ role.role }} {{ role.role }}
</div> </div>
</v-chip> </v-chip>
</v-col> </v-col>
</v-row> </v-row>
</template>
</v-container> </v-container>
</v-col> </v-col>
</v-row> </v-row>
@ -181,17 +183,11 @@ export default {
}, },
roles() { roles() {
if (!this.metadata) { return this.metadata?.Role?.slice(0, 6) || [];
return [];
}
return this.metadata.Role.slice(0, 6);
}, },
genres() { genres() {
if (!this.metadata) { return this.metadata?.Genre?.slice(0, 5) || [];
return [];
}
return this.metadata.Genre.slice(0, 5);
}, },
thumb() { thumb() {