Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

871 B
Raw Blame
import { useAppConfig } from "@editor/contexts/AppConfigContext";
import { useSelfHostedAuth } from "@editor/hooks/useSelfHostedAuth";

/**
 * Desktop override: shared (group) signing requires self-hosted mode AND
 * an authenticated session. Returns false in SaaS/local mode or when logged out.
 */
export function useGroupSigningEnabled(): boolean {
  return useGroupSigningState().enabled;
}

/** Waits for desktop mode, authentication and config before confirming availability. */
export function useGroupSigningState(): { enabled: boolean; settled: boolean } {
  const { config, loading: configLoading } = useAppConfig();
  const { isSelfHosted, isAuthenticated, loading } = useSelfHostedAuth();
  return {
    enabled:
      isSelfHosted &&
      isAuthenticated &&
      config?.storageGroupSigningEnabled === true,
    settled: !loading && !configLoading,
  };
}