Skip to content

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

771 B
Raw Blame
import { useAppConfig } from "@editor/contexts/AppConfigContext";
import { useSelfHostedAuth } from "@editor/hooks/useSelfHostedAuth";
import type { SharingEnabledResult } from "@editor-core/hooks/useSharingEnabled";

/**
 * Desktop override: file-sharing features require self-hosted mode AND an
 * authenticated session. Returns false for both in SaaS/local mode or when
 * logged out.
 */
export function useSharingEnabled(): SharingEnabledResult {
  const { config } = useAppConfig();
  const { isSelfHosted, isAuthenticated } = useSelfHostedAuth();
  const allowed = isSelfHosted && isAuthenticated;
  return {
    sharingEnabled: allowed && config?.storageSharingEnabled === true,
    shareLinksEnabled: allowed && config?.storageShareLinksEnabled === true,
  };
}