Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/features/dashboard/templates/list/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { TemplatesSort } from '@/core/modules/templates/models'

export const TEMPLATES_PAGE_SIZE = 50

export const TEMPLATES_REFETCH_INTERVAL_MS = 15_000

export const TEMPLATES_DEFAULT_SORT_COLUMN_ID = 'updatedAt'
export const TEMPLATES_DEFAULT_SORT_BASE = 'updated_at'
export const TEMPLATES_DEFAULT_SORT_DESC = true
Expand Down
4 changes: 4 additions & 0 deletions src/features/dashboard/templates/list/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
TEMPLATES_DEFAULT_SORT_BASE,
TEMPLATES_DEFAULT_SORT_DESC,
TEMPLATES_PAGE_SIZE,
TEMPLATES_REFETCH_INTERVAL_MS,
} from './constants'
import TemplatesHeader from './header'
import { useTemplateTableStore } from './stores/table-store'
Expand Down Expand Up @@ -92,6 +93,9 @@ export default function TemplatesTable() {
getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined,
initialCursor: undefined,
placeholderData: keepPreviousData,
refetchInterval: TEMPLATES_REFETCH_INTERVAL_MS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid polling every cached infinite page

When a team has enough templates for table-body.tsx to auto-load multiple pages, this interval makes TanStack's infinite query refetch every cached page every 15 seconds. Because this query has no maxPages cap or reset like the builds table, a user who has scrolled through 20 pages now generates 20 /templates requests per tick just by leaving the tab focused, so the polling cost grows with scroll depth and can hammer the API; consider capping cached pages or polling only the first page/list invalidation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kraci check this please

refetchIntervalInBackground: false,
refetchOnWindowFocus: true,
}
)
)
Expand Down
Loading