mirror of
https://github.com/outline/outline.git
synced 2026-11-26 23:50:14 +03:00
Moves lazyWithRetry to shared/utils so the editor's ColorSwatch and Mentions components can use it instead of React.lazy, avoiding the Suspense reveal throttle once the chunk is loaded.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { Suspense } from "react";
|
|
import useStores from "~/hooks/useStores";
|
|
import lazyWithRetry from "@shared/utils/lazyWithRetry";
|
|
import { DialogProvider } from "./DialogContext";
|
|
|
|
const Guide = lazyWithRetry(() => import("~/components/Guide"));
|
|
const Modal = lazyWithRetry(() => import("~/components/Modal"));
|
|
|
|
function Dialogs() {
|
|
const { dialogs } = useStores();
|
|
const { guide, modalStack } = dialogs;
|
|
const modals = [...modalStack];
|
|
|
|
return (
|
|
<DialogProvider>
|
|
<Suspense fallback={null}>
|
|
{guide ? (
|
|
<Guide
|
|
isOpen={guide.isOpen}
|
|
onRequestClose={dialogs.closeGuide}
|
|
title={guide.title}
|
|
>
|
|
{guide.content}
|
|
</Guide>
|
|
) : undefined}
|
|
{modals.map(([id, modal]) => (
|
|
<Modal
|
|
key={id}
|
|
isOpen={modal.isOpen}
|
|
onRequestClose={() => {
|
|
modal.onClose?.();
|
|
dialogs.closeModal(id);
|
|
}}
|
|
title={modal.title}
|
|
style={modal.style}
|
|
width={modal.width}
|
|
height={modal.height}
|
|
>
|
|
{modal.content}
|
|
</Modal>
|
|
))}
|
|
</Suspense>
|
|
</DialogProvider>
|
|
);
|
|
}
|
|
|
|
export default observer(Dialogs);
|