fix(Anime): fixed issue with anime timetable not refreshing

This commit is contained in:
Hakadao
2024-01-29 00:12:38 +08:00
parent a56887904e
commit d1827fd89c
2 changed files with 24 additions and 22 deletions

View File

@@ -15,21 +15,28 @@ const isLoadingPopularAnime = ref<boolean>()
const isLoadingRecommendAnime = ref<boolean>()
const activatedSeasonId = ref<number>()
const noMoreContent = ref<boolean>()
const noMoreContentWarning = ref<boolean>()
const animeTimeTableRef = ref()
const { handleReachBottom, handlePageRefresh } = useBewlyApp()
const isLoading = computed(() => {
return isLoadingAnimeWatchList.value || isLoadingPopularAnime.value || isLoadingRecommendAnime.value
})
onMounted(() => {
getAnimeWatchList()
getPopularAnimeList()
getRecommendAnimeList()
initPageAction()
})
function initPageAction() {
handleReachBottom.value = () => {
if (isLoadingRecommendAnime.value)
return
if (noMoreContent.value) {
noMoreContentWarning.value = true
if (noMoreContent.value)
return
}
getRecommendAnimeList()
}
handlePageRefresh.value = () => {
@@ -41,25 +48,14 @@ function initPageAction() {
popularAnimeList.length = 0
cursor.value = 0
noMoreContent.value = false
noMoreContentWarning.value = false
getAnimeWatchList()
getPopularAnimeList()
getRecommendAnimeList()
animeTimeTableRef.value?.refreshAnimeTimeTable()
}
}
onMounted(() => {
getAnimeWatchList()
getPopularAnimeList()
getRecommendAnimeList()
initPageAction()
})
onActivated(() => {
initPageAction()
})
function getAnimeWatchList() {
isLoadingAnimeWatchList.value = true
browser.runtime
@@ -244,7 +240,7 @@ function getPopularAnimeList() {
</h3>
</div>
<AnimeTimeTable w="[calc(100%+1.5rem)]" />
<AnimeTimeTable ref="animeTimeTableRef" w="[calc(100%+1.5rem)]" />
</section>
<!-- Recommended for you -->
@@ -279,7 +275,7 @@ function getPopularAnimeList() {
</div>
<!-- no more content -->
<Empty v-if="noMoreContentWarning" class="pb-4" :description="$t('common.no_more_content')" />
<Empty v-if="noMoreContent" class="pb-4" :description="$t('common.no_more_content')" />
<!-- loading -->
<loading v-if="isLoadingRecommendAnime && recommendAnimeList.length !== 0" m="-t-4" />

View File

@@ -2,13 +2,12 @@
import type { Ref } from 'vue'
import { useI18n } from 'vue-i18n'
import browser from 'webextension-polyfill'
import type { AnimeTimeTableItem } from '../types'
import { removeHttpFromUrl } from '~/utils/main'
import type { Result as TimetableItem, TimetableResult } from '~/models/apiModels/anime/timetable'
import type { Result as TimetableItem, TimetableResult } from '~/models/anime/timeTable'
const { t } = useI18n()
const animeTimeTable = reactive<AnimeTimeTableItem[]>([])
const animeTimeTable = reactive<TimetableItem[]>([])
const animeTimeTableWrap = ref<HTMLElement>() as Ref<HTMLElement>
const daysOfTheWeekList = computed(() => {
@@ -27,6 +26,11 @@ onMounted(() => {
getAnimeTimeTable()
})
function refreshAnimeTimeTable() {
animeTimeTable.length = 0
getAnimeTimeTable()
}
function getAnimeTimeTable() {
browser.runtime
.sendMessage({
@@ -38,6 +42,8 @@ function getAnimeTimeTable() {
Object.assign(animeTimeTable, result as TimetableItem[])
})
}
defineExpose({ refreshAnimeTimeTable })
</script>
<template>