Tried setting backdrop too fast, tries after mount & api response

This commit is contained in:
2022-08-15 21:06:59 +02:00
parent 609ebc3940
commit 2a9fc87350

View File

@@ -165,7 +165,7 @@
</template>
<script setup lang="ts">
import { ref, computed, defineProps } from "vue";
import { ref, computed, defineProps, onMounted } from "vue";
import { useStore } from "vuex";
// import img from "@/directives/v-image";
@@ -289,11 +289,17 @@
.then(() => getCredits(props.type))
.then(credits => setCast(credits?.cast || []))
.then(() => getRequestStatus(props.id, props.type))
.then(requestStatus => setRequested(requestStatus || false));
.then(requestStatus => setRequested(requestStatus || false))
.then(setBackdrop);
}
function setBackdrop(): void {
if (!media.value?.backdrop || !backdropElement.value?.style) return;
if (
!media.value?.backdrop ||
!backdropElement.value?.style ||
backdropElement.value?.style?.backgroundImage !== ""
)
return;
const backdropURL = `${ASSET_URL}${ASSET_SIZES[1]}${media.value.backdrop}`;
backdropElement.value.style.backgroundImage = `url(${backdropURL})`;
@@ -318,9 +324,10 @@
// On created functions
fetchMedia();
setBackdrop();
store.dispatch("torrentModule/setResultCount", null);
// End on create functions
onMounted(setBackdrop);
</script>
<style lang="scss" scoped>