From 457b0424f50212efe72af2baeaf7e4f116ad79f2 Mon Sep 17 00:00:00 2001 From: Tachibana Shin Date: Fri, 2 Aug 2024 04:03:37 +0000 Subject: [PATCH] (Fix: https://github.com/anime-vsub/app/issues/91) Refactor `_season.vue` to remove unnecessary whitespace and improve code readability --- src/pages/phim/_season.vue | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/pages/phim/_season.vue b/src/pages/phim/_season.vue index 30952b56..6c831d7e 100644 --- a/src/pages/phim/_season.vue +++ b/src/pages/phim/_season.vue @@ -731,12 +731,10 @@ const { data, run, error, loading } = useRequest( if (!id) return Promise.reject() - let result: Ref>> await Promise.any([ get(`data-${id}`).then((text: string) => { - if (!text) throw new Error("not_found") console.log("[fs]: use cache from fs %s", id) // eslint-disable-next-line promise/always-return @@ -744,7 +742,6 @@ const { data, run, error, loading } = useRequest( }), PhimId(realIdCurrentSeason.value) .then(async (data) => { - let changed = !result // true if result is undefined const watcher = result && @@ -917,10 +914,11 @@ async function fetchSeason(season: string) { console.log("data from internet is ", data) } responseOnlineStore.add(response) + + Object.assign(response.value, { [__ONLINE__]: true }) }), (promiseLoadIndexedb = get(`season_data ${realIdSeason}`).then( (json?: string) => { - if (!json) throw new Error("not_found") console.log("[fs]: use cache %s", realIdSeason) if (!response.value) response.value = JSON.parse(json) @@ -951,7 +949,6 @@ async function fetchSeason(season: string) { function watchHandler() { if (!seasons.value || !response.value) return - let indexMetaSeason = seasons.value.findIndex( (item) => item.value === season ) @@ -1009,7 +1006,6 @@ async function fetchSeason(season: string) { return responseOnlineStore.has(response) } - let watcherResponse: (() => void) | undefined = watch(response, () => { const doneAll = watchHandler() if (doneAll) { @@ -1095,7 +1091,6 @@ const currentProgresWatch = computed(() => { return undefined }) - let watcherChangeIdFirstEp: (() => void) | null = null onBeforeUnmount(() => watcherChangeIdFirstEp?.()) /** @type - currentChap is episode id */ @@ -1142,7 +1137,6 @@ watchEffect(async (onCleanup): Promise => { if (episodeId !== undefined) { if (episodeId) { - let watcher: () => void // eslint-disable-next-line prefer-const watcher = watchEffect(() => { @@ -1238,7 +1232,7 @@ watchEffect(() => { }) } else { if (import.meta.env.DEV) console.warn("Redirect to not_found") - if (data.value && __ONLINE__ in data.value) + if (data.value && __ONLINE__ in data.value && __ONLINE__ in currentDataSeason.value) router.replace({ name: "not_found", params: { @@ -1437,7 +1431,6 @@ watch( configPlayer.value = undefined - let typeCurrentConfig: keyof typeof servers | null = null let loadedServerFB = false @@ -1698,7 +1691,7 @@ async function addAnimePlaylist(idPlaylist: number) { name_season: metaSeason.name, chap: currentChap.value, name_chap: currentMetaChap.value.name, - season: currentSeason.value + season: currentSeason.value, }) $q.notify({ position: "bottom-right", @@ -1761,7 +1754,6 @@ const episodesOpEnd = computedAsync | null>( const controller = new AbortController() onCleanup(() => controller.abort()) - let results: ShallowReactive await Promise.any([ fetch( @@ -1789,7 +1781,6 @@ const episodesOpEnd = computedAsync | null>( } else results = shallowReactive(data) }), get(`episodes_opend:${realId}`).then((text: string) => { - if (!text) throw new Error("not_found_on_idb") const data = JSON.parse(text) @@ -1864,7 +1855,6 @@ const inoutroEpisode = computedAsync | null>( const { id } = episodeOpEnd.value - let results: ShallowReactive await Promise.any([ fetch(`${API_OPEND}/episode-skip/${id}`) @@ -1879,7 +1869,6 @@ const inoutroEpisode = computedAsync | null>( } else results = shallowReactive(data) }), get(`inoutro:${id}`).then((text: string) => { - if (!text) throw new Error("not_found_on_idb") const data = JSON.parse(text)