Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

936 B
Raw Blame
import { useQuery } from "@tanstack/react-query";
import { identityProviderServiceClient } from "@/connect";
import { IdentityProvider } from "@/types/proto/api/idp_service_pb";

// Query keys factory
export const identityProviderKeys = {
  all: ["identityProviders"] as const,
  list: () => [...identityProviderKeys.all, "list"] as const,
};

const EMPTY_LIST: IdentityProvider[] = [];

// Hook to fetch the configured identity providers. Pass `enabled: false` on
// pages/branches that never render provider buttons to skip the request.
export function useIdentityProviderList(enabled = true) {
  const { data, isLoading, isSuccess } = useQuery({
    queryKey: identityProviderKeys.list(),
    queryFn: async () => (await identityProviderServiceClient.listIdentityProviders({})).identityProviders,
    staleTime: 60_000,
    enabled,
  });
  return {
    identityProviderList: data ?? EMPTY_LIST,
    isLoading,
    isSuccess,
  };
}