mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
perf: fix render cycle in useBranding and conditional polling
- Remove isFullscreen from useBranding useEffect deps to prevent re-render loop (requestFullscreen changes isFullscreen which re-triggers the effect); use ref guard instead - Make AdminBroadcasts 5s polling conditional: only poll when there are active broadcasts (queued/in_progress/cancelling)
This commit is contained in:
@@ -137,7 +137,13 @@ export default function AdminBroadcasts() {
|
||||
const { data, isLoading, refetch } = useQuery({
|
||||
queryKey: ['admin', 'broadcasts', 'list', page],
|
||||
queryFn: () => adminBroadcastsApi.list(limit, page * limit),
|
||||
refetchInterval: 5000, // Auto refresh every 5s
|
||||
refetchInterval: (query) => {
|
||||
const items = query.state.data?.items;
|
||||
const hasActive = items?.some((b: { status: string }) =>
|
||||
['queued', 'in_progress', 'cancelling'].includes(b.status),
|
||||
);
|
||||
return hasActive ? 5000 : false;
|
||||
},
|
||||
});
|
||||
|
||||
const broadcasts = data?.items || [];
|
||||
|
||||
Reference in New Issue
Block a user