mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
16 lines
401 B
TypeScript
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
|
|
);
|
|
}
|