Skip to content

Commit 43ab6f5

Browse files
committed
feat(hooks): add default polling interval for task items updates
1 parent f63164e commit 43ab6f5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/app/src/hooks/use-task-items.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { useCallback } from 'react';
66

77
export type TaskItemEntityType = 'vendor' | 'risk';
88

9+
// Default polling interval for cross-user updates (5 seconds)
10+
const DEFAULT_TASK_ITEMS_POLLING_INTERVAL = 5000;
11+
912
export type TaskItemStatus = 'todo' | 'in_progress' | 'in_review' | 'done' | 'canceled';
1013

1114
export type TaskItemPriority = 'urgent' | 'high' | 'medium' | 'low';
@@ -211,6 +214,9 @@ export function useTaskItems(
211214

212215
return useApiSWR<PaginatedTaskItemsResponse>(endpoint, {
213216
...options,
217+
// Cross-user updates: when another teammate edits tasks, this view should update without refresh
218+
refreshInterval: options.refreshInterval ?? DEFAULT_TASK_ITEMS_POLLING_INTERVAL,
219+
revalidateOnFocus: options.revalidateOnFocus ?? true,
214220
// Keep previous data visible while loading new page
215221
keepPreviousData: true,
216222
});
@@ -229,7 +235,11 @@ export function useTaskItemsStats(
229235
? `/v1/task-management/stats?entityId=${entityId}&entityType=${entityType}`
230236
: null;
231237

232-
return useApiSWR<TaskItemsStats>(endpoint, options);
238+
return useApiSWR<TaskItemsStats>(endpoint, {
239+
...options,
240+
refreshInterval: options.refreshInterval ?? DEFAULT_TASK_ITEMS_POLLING_INTERVAL,
241+
revalidateOnFocus: options.revalidateOnFocus ?? true,
242+
});
233243
}
234244

235245
/**

0 commit comments

Comments
 (0)