Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

660 B
Raw Blame
import { type ModalInstance } from '@lobehub/ui';

import { type OpenShareModalOptions } from './Modal';

const importShareModal = () => import('./Modal');

let shareModalModulePromise: ReturnType<typeof importShareModal> | undefined;

export const preloadShareModal = (): ReturnType<typeof importShareModal> =>
  (shareModalModulePromise ??= importShareModal().catch((error) => {
    shareModalModulePromise = undefined;
    throw error;
  }));

export const openShareModal = async (options?: OpenShareModalOptions): Promise<ModalInstance> => {
  const { openShareModal: createShareModal } = await preloadShareModal();

  return createShareModal(options);
};