From d1827fd89cf21d4e2cd46dd0aa39a2b77a47e0ff Mon Sep 17 00:00:00 2001 From: Hakadao Date: Mon, 29 Jan 2024 00:12:38 +0800 Subject: [PATCH] fix(Anime): fixed issue with anime timetable not refreshing --- src/contentScripts/views/Anime/Anime.vue | 34 ++++++++----------- .../views/Anime/components/AnimeTimeTable.vue | 12 +++++-- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/contentScripts/views/Anime/Anime.vue b/src/contentScripts/views/Anime/Anime.vue index 095fbb79..9a718cb5 100644 --- a/src/contentScripts/views/Anime/Anime.vue +++ b/src/contentScripts/views/Anime/Anime.vue @@ -15,21 +15,28 @@ const isLoadingPopularAnime = ref() const isLoadingRecommendAnime = ref() const activatedSeasonId = ref() const noMoreContent = ref() -const noMoreContentWarning = ref() +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() { - + @@ -279,7 +275,7 @@ function getPopularAnimeList() { - + diff --git a/src/contentScripts/views/Anime/components/AnimeTimeTable.vue b/src/contentScripts/views/Anime/components/AnimeTimeTable.vue index 754baa07..2063e022 100644 --- a/src/contentScripts/views/Anime/components/AnimeTimeTable.vue +++ b/src/contentScripts/views/Anime/components/AnimeTimeTable.vue @@ -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([]) +const animeTimeTable = reactive([]) const animeTimeTableWrap = ref() as Ref 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 })