Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

899 B
Raw Blame
import { useExitPresence } from '@platform/react/useExitRetainedValue';
import { lazy, Suspense } from 'react';

import { layoutPresetManagerStore } from './layoutPresetManagerStore';

/** Lazy-load the infrequently used preset manager outside the editor's initial payload. */
const LazyLayoutPresetManagerDialogBody = lazy(() =>
  import('./LayoutPresetManagerDialogBody').then((module) => ({ default: module.LayoutPresetManagerDialogBody }))
);

export const LayoutPresetManagerDialog = () => {
  const isOpen = layoutPresetManagerStore.useSelector((snapshot) => snapshot.isOpen);
  // Stays mounted through the close animation instead of vanishing with the open state.
  const dialog = useExitPresence(isOpen);

  return dialog.isMounted ? (
    <Suspense fallback={null}>
      <LazyLayoutPresetManagerDialogBody isOpen={isOpen} onExitComplete={dialog.release} />
    </Suspense>
  ) : null;
};