Fetch credits async in separated call from info
This commit is contained in:
		| @@ -46,12 +46,7 @@ | |||||||
|           </sidebar-list-element> |           </sidebar-list-element> | ||||||
|  |  | ||||||
|           <sidebar-list-element |           <sidebar-list-element | ||||||
|             v-if=" |             v-if="credits && credits.cast && credits.cast.length" | ||||||
|               movie && |  | ||||||
|               movie.credits && |  | ||||||
|               movie.credits.cast && |  | ||||||
|               movie.credits.cast.length |  | ||||||
|             " |  | ||||||
|             :active="showCast" |             :active="showCast" | ||||||
|             @click="() => (showCast = !showCast)" |             @click="() => (showCast = !showCast)" | ||||||
|           > |           > | ||||||
| @@ -139,16 +134,10 @@ | |||||||
|  |  | ||||||
|         <div |         <div | ||||||
|           class="movie__admin" |           class="movie__admin" | ||||||
|           v-if=" |           v-if="showCast && credits && credits.cast && credits.cast.length" | ||||||
|             showCast && |  | ||||||
|             movie && |  | ||||||
|             movie.credits && |  | ||||||
|             movie.credits.cast && |  | ||||||
|             movie.credits.cast.length |  | ||||||
|           " |  | ||||||
|         > |         > | ||||||
|           <MovieDetail title="cast"> |           <MovieDetail title="cast"> | ||||||
|             <Cast :cast="movie.credits.cast" /> |             <Cast :cast="credits.cast" /> | ||||||
|           </MovieDetail> |           </MovieDetail> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
| @@ -186,8 +175,9 @@ import LoadingPlaceholder from "./ui/LoadingPlaceholder"; | |||||||
|  |  | ||||||
| import { | import { | ||||||
|   getMovie, |   getMovie, | ||||||
|   getPerson, |  | ||||||
|   getShow, |   getShow, | ||||||
|  |   getPerson, | ||||||
|  |   getCredits, | ||||||
|   request, |   request, | ||||||
|   getRequestStatus, |   getRequestStatus, | ||||||
|   watchLink |   watchLink | ||||||
| @@ -234,17 +224,14 @@ export default { | |||||||
|       requested: false, |       requested: false, | ||||||
|       showTorrents: false, |       showTorrents: false, | ||||||
|       showCast: false, |       showCast: false, | ||||||
|  |       credits: [], | ||||||
|       compact: false, |       compact: false, | ||||||
|       loading: true |       loading: true | ||||||
|     }; |     }; | ||||||
|   }, |   }, | ||||||
|   watch: { |   watch: { | ||||||
|     id: function (val) { |     id: function (val) { | ||||||
|       if (this.type === "movie") { |       this.fetchByType(); | ||||||
|         this.fetchMovie(val); |  | ||||||
|       } else { |  | ||||||
|         this.fetchShow(val); |  | ||||||
|       } |  | ||||||
|     }, |     }, | ||||||
|     backdrop: function (backdrop) { |     backdrop: function (backdrop) { | ||||||
|       if (backdrop != null) { |       if (backdrop != null) { | ||||||
| @@ -265,6 +252,26 @@ export default { | |||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|  |     fetchByType() { | ||||||
|  |       if (this.type === "movie") { | ||||||
|  |         getMovie(this.id, true, false) | ||||||
|  |           .then(this.parseResponse) | ||||||
|  |           .catch(error => { | ||||||
|  |             this.$router.push({ name: "404" }); | ||||||
|  |           }); | ||||||
|  |       } else if (this.type == "show") { | ||||||
|  |         getShow(this.id, false, false) | ||||||
|  |           .then(this.parseResponse) | ||||||
|  |           .catch(error => { | ||||||
|  |             this.$router.push({ name: "404" }); | ||||||
|  |           }); | ||||||
|  |       } else { | ||||||
|  |         this.$router.push({ name: "404" }); | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       // async get credits | ||||||
|  |       getCredits(this.type, this.id).then(credits => (this.credits = credits)); | ||||||
|  |     }, | ||||||
|     parseResponse(movie) { |     parseResponse(movie) { | ||||||
|       this.loading = false; |       this.loading = false; | ||||||
|       this.movie = { ...movie }; |       this.movie = { ...movie }; | ||||||
| @@ -323,22 +330,7 @@ export default { | |||||||
|   }, |   }, | ||||||
|   created() { |   created() { | ||||||
|     this.prevDocumentTitle = store.getters["documentTitle/title"]; |     this.prevDocumentTitle = store.getters["documentTitle/title"]; | ||||||
|  |     this.fetchByType(); | ||||||
|     if (this.type === "movie") { |  | ||||||
|       getMovie(this.id, true, true) |  | ||||||
|         .then(this.parseResponse) |  | ||||||
|         .catch(error => { |  | ||||||
|           this.$router.push({ name: "404" }); |  | ||||||
|         }); |  | ||||||
|     } else if (this.type == "show") { |  | ||||||
|       getShow(this.id, false, true) |  | ||||||
|         .then(this.parseResponse) |  | ||||||
|         .catch(error => { |  | ||||||
|           this.$router.push({ name: "404" }); |  | ||||||
|         }); |  | ||||||
|     } else { |  | ||||||
|       this.$router.push({ name: "404" }); |  | ||||||
|     } |  | ||||||
|   }, |   }, | ||||||
|   beforeDestroy() { |   beforeDestroy() { | ||||||
|     store.dispatch("documentTitle/updateTitle", this.prevDocumentTitle); |     store.dispatch("documentTitle/updateTitle", this.prevDocumentTitle); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user