Skip to content

Commit 3cfee5c

Browse files
committed
feat(VisitList): 検索条件なし&1ページ目の場合に30秒自動リフレッシュを追加
- RTK QueryのpollingIntervalを使用して30秒ごとにデータを再取得 - 自動リフレッシュ中(既存データあり)はLoading Overlayを非表示
1 parent 46a7b0d commit 3cfee5c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

frontend/src/pages/VisitsBrowser/VisitList/VisitList.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,19 @@ export function VisitList() {
771771
return `where ${conditions.join(' and ')}`
772772
}, [appliedSql, dateRange, exposureFilters])
773773

774+
// 自動リフレッシュ:検索条件なし&1ページ目の場合は30秒ごとに更新
775+
const shouldAutoRefresh = useMemo(() => {
776+
return effectiveSql === undefined && offset === 0
777+
}, [effectiveSql, offset])
778+
774779
// RTK Query API - include sql parameter when set
780+
// pollingIntervalで30秒ごとの自動リフレッシュを実現
775781
const { data, isLoading, isFetching, isError, error, refetch } = useListVisitsApiVisitsGetQuery({
776782
offset,
777783
limit,
778784
sql: effectiveSql,
785+
}, {
786+
pollingInterval: shouldAutoRefresh ? 30000 : 0, // 30秒 = 30000ms
779787
})
780788

781789
// Lazy query for Go to Visit feature
@@ -1206,7 +1214,8 @@ export function VisitList() {
12061214
</div>
12071215

12081216
<div className={styles.content} ref={contentRef}>
1209-
<LoadingOverlay isLoading={isFetching || isLoadingMore} stickyCenter />
1217+
{/* 自動リフレッシュ時(データ取得済み&ポーリング中)はLoading Overlayを非表示 */}
1218+
<LoadingOverlay isLoading={(isFetching || isLoadingMore) && !(shouldAutoRefresh && data)} stickyCenter />
12101219

12111220
{/* Navigation at top - scrolls with content */}
12121221
<div className={styles.paginationTop}>

0 commit comments

Comments
 (0)