Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

107 down player if view trailer #108

Merged
merged 2 commits into from
Apr 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions src/pages/phim/_season.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
})
"
/>
<div v-else class="w-full overflow-hidden fixed top-0 left-0 z-200">
<div
v-else
class="w-full overflow-hidden bg-[#000] focus-visible:outline-none select-none"
>
<q-img
no-spinner
v-if="sources?.[0]?.url"
v-if="!sources?.[0]?.url"
:ratio="841 / 483"
class="max-h-[calc(100vh-169px)] max-w-[100px]"
src="~assets/ic_question_result_error.png"
Expand Down Expand Up @@ -401,7 +404,6 @@
<script lang="ts" setup>
import { getAnalytics, logEvent } from "@firebase/analytics"
import { Icon } from "@iconify/vue"
import { computedAsync } from "@vueuse/core"
import { useHead } from "@vueuse/head"
import AddToPlaylist from "components/AddToPlaylist.vue"
import BrtPlayer from "components/BrtPlayer.vue"
Expand Down Expand Up @@ -671,7 +673,7 @@ async function fetchSeason(season: string) {
console.warn("chaps not found")
response.chaps = [
{
id: "#youtube",
id: "0",
play: "1",

hash:
Expand Down Expand Up @@ -778,14 +780,22 @@ const resetPromiseDefCurrentChap = () => {
}
onBeforeUnmount(resetPromiseDefCurrentChap)
/** @type - currentChap is episode id */
const currentChap = computedAsync(async () => {
const currentChap = ref<string>()
watchEffect(async (): Promise<void> => {
resetPromiseDefCurrentChap()

if (route.params.chap) return route.params.chap as string
if (route.params.chap) {
currentChap.value = route.params.chap as string
return
}
currentChap.value = undefined
// if this does not exist make sure the status has not finished loading, this function call also useless

// if not login -> return first episode in season
if (!authStore.uid) return currentDataSeason.value?.chaps[0].id
if (!authStore.uid) {
currentChap.value = currentDataSeason.value?.chaps[0].id
return
}

const episodeId = await Promise.race([
// if logged -> get last episode viewing in season
Expand All @@ -811,10 +821,11 @@ const currentChap = computedAsync(async () => {
resetPromiseDefCurrentChap()
// if not exists -> return first episode in season
if (episodeId === null) {
return currentDataSeason.value?.chaps[0].id
currentChap.value = currentDataSeason.value?.chaps[0].id
return
}

return episodeId
currentChap.value = episodeId
})
const currentMetaChap = computed(() => {
if (!currentChap.value) return
Expand Down Expand Up @@ -843,8 +854,8 @@ watchEffect(() => {
watchEffect(() => {
// currentChap != undefined because is load done from firestore and ready show but in chaps not found (!currentMetaChap.value)
if (
currentDataSeason.value &&
currentChap.value !== undefined &&
currentDataSeason.value?.chaps &&
currentChap.value &&
!currentMetaChap.value
) {
router.replace({
Expand Down Expand Up @@ -1033,7 +1044,7 @@ watch(

configPlayer.value = undefined

if (currentMetaChap.id === "#youtube") {
if (currentMetaChap.id === "0") {
configPlayer.value = {
link: [
{
Expand Down