From 70dddc80b5a9ae3576fafcb63861530a450fc907 Mon Sep 17 00:00:00 2001 From: hakadao Date: Sun, 2 Jun 2024 13:40:11 +0800 Subject: [PATCH] fix(WatchLater): correct the inaccurate video count --- .../views/WatchLater/WatchLater.vue | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/contentScripts/views/WatchLater/WatchLater.vue b/src/contentScripts/views/WatchLater/WatchLater.vue index df98cd4b..959d01d7 100644 --- a/src/contentScripts/views/WatchLater/WatchLater.vue +++ b/src/contentScripts/views/WatchLater/WatchLater.vue @@ -17,6 +17,7 @@ const isLoading = ref() const noMoreContent = ref() const allWatchLaterList = ref([]) const currentWatchLaterList = ref([]) +const watchLaterCount = ref(0) const { handlePageRefresh, handleReachBottom } = useBewlyApp() const pageNum = ref(1) @@ -60,8 +61,10 @@ async function getAllWatchLaterList() { currentWatchLaterList.value.length = 0 try { const res: WatchLaterResult = await api.watchlater.getAllWatchLaterList() - if (res.code === 0) + if (res.code === 0) { allWatchLaterList.value = res.data.list + watchLaterCount.value = allWatchLaterList.value.length + } } finally { isLoading.value = false @@ -86,8 +89,10 @@ function deleteWatchLaterItem(index: number, aid: number) { csrf: getCSRF(), }) .then((res) => { - if (res.code === 0) + if (res.code === 0) { currentWatchLaterList.value.splice(index, 1) + watchLaterCount.value-- + } }) } @@ -137,9 +142,9 @@ function jumpToLoginPage() {

- {{ t('watch_later.title') }} ({{ allWatchLaterList.length }}) + {{ t('watch_later.title') }} ({{ watchLaterCount }})

- +