diff --git a/apps/admin-web/src/views/TemplatesView.vue b/apps/admin-web/src/views/TemplatesView.vue index 56d0fc1..17d41f7 100644 --- a/apps/admin-web/src/views/TemplatesView.vue +++ b/apps/admin-web/src/views/TemplatesView.vue @@ -14,7 +14,6 @@ import type { ArticleListItem, ArticleListParams, KolWorkspaceCard, - RecentArticle, TemplateListItem, } from '@geo/shared-types' import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query' @@ -94,17 +93,6 @@ const kolCardsQuery = useQuery({ queryFn: () => workspaceApi.kolCards(), }) -const recentArticlesQuery = useQuery({ - queryKey: computed(() => [ - 'workspace', - 'recent-articles', - 'templates', - companyStore.currentBrandId, - ]), - enabled: computed(() => Boolean(companyStore.currentBrandId)), - queryFn: () => workspaceApi.recentArticles(), -}) - const articleParams = computed(() => { const params: ArticleListParams = { page: page.value, @@ -147,65 +135,11 @@ const articleListQuery = useQuery({ queryFn: () => articlesApi.list(articleParams.value), }) -const hasActiveRecordFilters = computed(() => - Boolean( - appliedFilters.template_filter || - appliedFilters.publish_status || - appliedFilters.generate_status || - appliedFilters.keyword?.trim() || - appliedFilters.created_from || - appliedFilters.created_to, - ), -) - -const recentTemplateArticles = computed(() => - (recentArticlesQuery.data.value || []) - .filter( - (article: RecentArticle) => - article.source_type === 'template' || article.source_type === 'kol', - ) - .map((article: RecentArticle) => ({ - id: article.id, - source_type: article.source_type, - template_id: null, - kol_prompt_id: null, - template_name: - article.template_name || - (article.source_type === 'kol' - ? t('templates.sections.refinedTemplates') - : t('templates.sections.generalTemplates')), - prompt_rule_id: null, - prompt_rule_name: null, - generation_mode: article.generation_mode, - auto_publish_platforms: [], - generate_status: article.generate_status, - publish_status: article.publish_status, - title: article.title, - generation_error_message: null, - word_count: article.word_count, - source_label: article.source_label, - created_at: article.created_at, - })), -) - -const shouldUseRecentFallback = computed( - () => - !hasActiveRecordFilters.value && - (articleListQuery.data.value?.total ?? 0) === 0 && - recentTemplateArticles.value.length > 0, -) - const displayedArticles = computed(() => - shouldUseRecentFallback.value - ? recentTemplateArticles.value - : articleListQuery.data.value?.items || [], + articleListQuery.data.value?.items || [], ) -const displayedArticleTotal = computed(() => - shouldUseRecentFallback.value - ? recentTemplateArticles.value.length - : articleListQuery.data.value?.total || 0, -) +const displayedArticleTotal = computed(() => articleListQuery.data.value?.total || 0) let articlePollingTimer: number | null = null const ARTICLE_LIST_POLL_INTERVAL_MS = 5000 @@ -287,18 +221,14 @@ const articleColumns = computed>(() => [ }, ]) -const articlePagination = computed(() => - shouldUseRecentFallback.value - ? false - : { - current: page.value, - pageSize: pageSize.value, - total: displayedArticleTotal.value, - showSizeChanger: true, - onChange: handleTableChange, - onShowSizeChange: handleTableChange, - }, -) +const articlePagination = computed(() => ({ + current: page.value, + pageSize: pageSize.value, + total: displayedArticleTotal.value, + showSizeChanger: true, + onChange: handleTableChange, + onShowSizeChange: handleTableChange, +})) // removed wizard watch effect @@ -449,13 +379,6 @@ function startArticlePolling(): void { } articlePollingTimer = window.setInterval(() => { - if (shouldUseRecentFallback.value) { - if (!recentArticlesQuery.isFetching.value) { - void recentArticlesQuery.refetch() - } - return - } - if (!articleListQuery.isFetching.value) { void articleListQuery.refetch() } @@ -493,7 +416,7 @@ async function copyArticle(articleId: number): Promise { } function refreshRecords(): void { - void Promise.all([articleListQuery.refetch(), recentArticlesQuery.refetch()]) + void articleListQuery.refetch() } @@ -602,7 +525,7 @@ function refreshRecords(): void { class="templates-view__desktop-table" :columns="articleColumns" :data-source="displayedArticles" - :loading="articleListQuery.isPending.value || recentArticlesQuery.isPending.value" + :loading="articleListQuery.isPending.value" row-key="id" :pagination="articlePagination" :scroll="{ x: 1068 }" @@ -657,7 +580,7 @@ function refreshRecords(): void {
@@ -720,7 +643,6 @@ function refreshRecords(): void {