fix crash on chapters

This commit is contained in:
Bnyro 2022-07-22 20:50:21 +02:00
parent a4588b643f
commit adead97b23

View File

@ -10,7 +10,7 @@
@click="$emit('seek', chapter.start)" @click="$emit('seek', chapter.start)"
class="chapter-vertical" class="chapter-vertical"
:class=" :class="
playerPosition >= chapter.start && playerPosition < chapters[index + 1].start isCurrentChapter(chapters, index, playerPosition)
? 'chapter-vertical bg-red-500/50' ? 'chapter-vertical bg-red-500/50'
: 'chapter-vertical' : 'chapter-vertical'
" "
@ -29,13 +29,9 @@
<div v-else class="flex overflow-x-auto"> <div v-else class="flex overflow-x-auto">
<div <div
:key="chapter.start" :key="chapter.start"
v-for="(chapter, index) in chapters" v-for="chapter in chapters"
@click="$emit('seek', chapter.start)" @click="$emit('seek', chapter.start)"
:class=" :class="isCurrentChapter(chapters, index, playerPosition) ? 'chapter bg-red-500/50' : 'chapter'"
playerPosition >= chapter.start && playerPosition < chapters[index + 1].start
? 'chapter bg-red-500/50'
: 'chapter'
"
> >
<img :src="chapter.image" :alt="chapter.title" /> <img :src="chapter.image" :alt="chapter.title" />
<div class="m-1 flex"> <div class="m-1 flex">
@ -70,6 +66,19 @@
} }
</style> </style>
<script>
export default {
methods: {
isCurrentChapter(chapters, index, playerPosition) {
if (index + 1 === chapters.length && playerPosition >= chapters[index].start) return true;
else if (index + 1 === chapters.length) return false;
else if (playerPosition >= chapters[index].start && playerPosition < chapters[index + 1].start) return true;
return false;
},
},
};
</script>
<script setup> <script setup>
import { defineProps, defineEmits } from "vue"; import { defineProps, defineEmits } from "vue";