alby-hub/frontend/src/hooks/useChannels.ts
2026-05-19 18:26:54 +02:00

16 lines
401 B
TypeScript

import useSWR, { SWRConfiguration } from "swr";
import { Channel } from "src/types";
import { swrFetcher } from "src/utils/swr";
const pollConfiguration: SWRConfiguration = {
refreshInterval: 3000,
};
export function useChannels(poll = false, enabled = true) {
return useSWR<Channel[]>(
enabled ? "/api/channels" : undefined,
swrFetcher,
poll ? pollConfiguration : undefined
);
}