Person's credits are converted to movie & show so can check type attr
This commit is contained in:
@@ -38,11 +38,19 @@
|
|||||||
<MovieDescription :description="person.biography" />
|
<MovieDescription :description="person.biography" />
|
||||||
</MovieDetail>
|
</MovieDetail>
|
||||||
|
|
||||||
<MovieDetail title="movies" v-if="credits">
|
<MovieDetail
|
||||||
|
title="movies"
|
||||||
|
:detail="`Credited in ${movieCredits.length} movies`"
|
||||||
|
v-if="credits"
|
||||||
|
>
|
||||||
<Cast :cast="movieCredits" />
|
<Cast :cast="movieCredits" />
|
||||||
</MovieDetail>
|
</MovieDetail>
|
||||||
|
|
||||||
<MovieDetail title="shows" v-if="credits">
|
<MovieDetail
|
||||||
|
title="shows"
|
||||||
|
:detail="`Credited in ${showCredits.length} shows`"
|
||||||
|
v-if="credits"
|
||||||
|
>
|
||||||
<Cast :cast="showCredits" />
|
<Cast :cast="showCredits" />
|
||||||
</MovieDetail>
|
</MovieDetail>
|
||||||
</div>
|
</div>
|
||||||
@@ -87,13 +95,6 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
id: function (val) {
|
|
||||||
if (this.type === "person") {
|
|
||||||
this.fetchperson(val);
|
|
||||||
} else {
|
|
||||||
this.fetchShow(val);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
backdrop: function (backdrop) {
|
backdrop: function (backdrop) {
|
||||||
if (backdrop != null) {
|
if (backdrop != null) {
|
||||||
const style = {
|
const style = {
|
||||||
@@ -120,7 +121,7 @@ export default {
|
|||||||
if (!cast) return;
|
if (!cast) return;
|
||||||
|
|
||||||
return cast
|
return cast
|
||||||
.filter(l => l.media_type === "movie")
|
.filter(l => l.type === "movie")
|
||||||
.filter((item, pos, self) => self.indexOf(item) == pos)
|
.filter((item, pos, self) => self.indexOf(item) == pos)
|
||||||
.sort((a, b) => a.popularity < b.popularity);
|
.sort((a, b) => a.popularity < b.popularity);
|
||||||
},
|
},
|
||||||
@@ -129,12 +130,12 @@ export default {
|
|||||||
if (!cast) return;
|
if (!cast) return;
|
||||||
|
|
||||||
const alreadyExists = (item, pos, self) => {
|
const alreadyExists = (item, pos, self) => {
|
||||||
const names = self.map(item => item.name);
|
const names = self.map(item => item.title);
|
||||||
return names.indexOf(item.name) == pos;
|
return names.indexOf(item.title) == pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
return cast
|
return cast
|
||||||
.filter(item => item.media_type === "tv")
|
.filter(item => item.type === "show")
|
||||||
.filter(alreadyExists)
|
.filter(alreadyExists)
|
||||||
.sort((a, b) => a.popularity < b.popularity);
|
.sort((a, b) => a.popularity < b.popularity);
|
||||||
}
|
}
|
||||||
@@ -159,18 +160,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
getPerson(this.id, true)
|
getPerson(this.id, false)
|
||||||
.then(this.parseResponse)
|
.then(this.parseResponse)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.$router.push({ name: "404" });
|
this.$router.push({ name: "404" });
|
||||||
});
|
});
|
||||||
|
|
||||||
getPersonCredits(this.id, true)
|
getPersonCredits(this.id)
|
||||||
.then(credits => (this.credits = credits))
|
.then(credits => (this.credits = credits))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.$router.push({ name: "404" });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user