From 11d9cf669ddff6db638958d3f201bb0504e8d42d Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 24 Feb 2023 14:28:13 +0800 Subject: [PATCH] perf: improve the conditions for categories and tags automatic refresh (halo-dev/console#883) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement #### What this PR does / why we need it: 优化分类和标签管理页面自动刷新的条件,现在支持检测 `status.permalink` 是否已经生成完毕,如果没有会自动刷新列表。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3376 #### Special notes for your reviewer: 测试方式: 1. 测试添加若干分类和标签,观测在没有生成 permalink 的情况下,是否会自动刷新列表。 #### Does this PR introduce a user-facing change? ```release-note 优化 Console 端分类和标签管理的自动刷新条件,支持检测固定链接是否已经生成。 ``` --- .../posts/categories/composables/use-post-category.ts | 7 ++++--- .../contents/posts/tags/composables/use-post-tag.ts | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/contents/posts/categories/composables/use-post-category.ts b/src/modules/contents/posts/categories/composables/use-post-category.ts index d800d7f61..556cde279 100644 --- a/src/modules/contents/posts/categories/composables/use-post-category.ts +++ b/src/modules/contents/posts/categories/composables/use-post-category.ts @@ -34,10 +34,11 @@ export function usePostCategory(): usePostCategoryReturn { return data.items; }, refetchInterval(data) { - const deletingCategories = data?.filter( - (category) => !!category.metadata.deletionTimestamp + const abnormalCategories = data?.filter( + (category) => + !!category.metadata.deletionTimestamp || !category.status?.permalink ); - return deletingCategories?.length ? 3000 : false; + return abnormalCategories?.length ? 3000 : false; }, refetchOnWindowFocus: false, onSuccess(data) { diff --git a/src/modules/contents/posts/tags/composables/use-post-tag.ts b/src/modules/contents/posts/tags/composables/use-post-tag.ts index cd2d60f5c..2689016c8 100644 --- a/src/modules/contents/posts/tags/composables/use-post-tag.ts +++ b/src/modules/contents/posts/tags/composables/use-post-tag.ts @@ -28,10 +28,10 @@ export function usePostTag(): usePostTagReturn { return data.items; }, refetchInterval(data) { - const deletingTags = data?.filter( - (tag) => !!tag.metadata.deletionTimestamp + const abnormalTags = data?.filter( + (tag) => !!tag.metadata.deletionTimestamp || !tag.status?.permalink ); - return deletingTags?.length ? 3000 : false; + return abnormalTags?.length ? 3000 : false; }, refetchOnWindowFocus: false, });