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:
Fringg
2026-02-23 17:15:20 +03:00
parent 7cf72735ec
commit 30ece694d4
2 changed files with 15 additions and 6 deletions

View File

@@ -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 || [];