From 568ebf5b7091450e3a9c6e634168151c5ea2a297 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 19 Aug 2025 15:03:16 +0800 Subject: [PATCH] Fix pending comments calculation in post list item (#7703) #### What type of PR is this? /area ui /kind bug /milestone 2.21.x #### What this PR does / why we need it: Fix pending comments calculation in post list item #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../contents/pages/components/entity-fields/TitleField.vue | 6 +----- .../contents/posts/components/entity-fields/TitleField.vue | 6 +----- .../widgets/presets/posts/components/PostListItem.vue | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/ui/console-src/modules/contents/pages/components/entity-fields/TitleField.vue b/ui/console-src/modules/contents/pages/components/entity-fields/TitleField.vue index bc006e348..6363e638a 100644 --- a/ui/console-src/modules/contents/pages/components/entity-fields/TitleField.vue +++ b/ui/console-src/modules/contents/pages/components/entity-fields/TitleField.vue @@ -38,11 +38,7 @@ const commentText = computed(() => { comments: totalComment || 0, }); - if (!totalComment || !approvedComment) { - return text; - } - - const pendingComments = totalComment - approvedComment; + const pendingComments = (totalComment || 0) - (approvedComment || 0); if (pendingComments > 0) { text += t("core.page.list.fields.comments-with-pending", { diff --git a/ui/console-src/modules/contents/posts/components/entity-fields/TitleField.vue b/ui/console-src/modules/contents/posts/components/entity-fields/TitleField.vue index 1599db6cc..f385a3da6 100644 --- a/ui/console-src/modules/contents/posts/components/entity-fields/TitleField.vue +++ b/ui/console-src/modules/contents/posts/components/entity-fields/TitleField.vue @@ -39,11 +39,7 @@ const commentText = computed(() => { comments: totalComment || 0, }); - if (!totalComment || !approvedComment) { - return text; - } - - const pendingComments = totalComment - approvedComment; + const pendingComments = (totalComment || 0) - (approvedComment || 0); if (pendingComments > 0) { text += t("core.post.list.fields.comments-with-pending", { diff --git a/ui/console-src/modules/dashboard/widgets/presets/posts/components/PostListItem.vue b/ui/console-src/modules/dashboard/widgets/presets/posts/components/PostListItem.vue index 9d8bb25ff..3448d5313 100644 --- a/ui/console-src/modules/dashboard/widgets/presets/posts/components/PostListItem.vue +++ b/ui/console-src/modules/dashboard/widgets/presets/posts/components/PostListItem.vue @@ -48,11 +48,7 @@ const commentText = computed(() => { comments: totalComment || 0, }); - if (!totalComment || !approvedComment) { - return text; - } - - const pendingComments = totalComment - approvedComment; + const pendingComments = (totalComment || 0) - (approvedComment || 0); if (pendingComments > 0) { text += t(