mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-12 12:38:42 +00:00
Fix lazy loading of context modals (#11911)
This commit is contained in:
@@ -1,7 +1,13 @@
|
|||||||
import {} from '@mantine/core';
|
import {} from '@mantine/core';
|
||||||
import type { ContextModalProps } from '@mantine/modals';
|
import type { ContextModalProps } from '@mantine/modals';
|
||||||
|
import { lazy } from 'react';
|
||||||
import type { NavigateFunction } from 'react-router-dom';
|
import type { NavigateFunction } from 'react-router-dom';
|
||||||
import { ScanInputHandler } from '../barcodes/BarcodeScanDialog';
|
|
||||||
|
const ScanInputHandler = lazy(() =>
|
||||||
|
import('../barcodes/BarcodeScanDialog').then((module) => ({
|
||||||
|
default: module.ScanInputHandler
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
export function QrModal({
|
export function QrModal({
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -8,35 +8,16 @@ import {
|
|||||||
import { ModalsProvider } from '@mantine/modals';
|
import { ModalsProvider } from '@mantine/modals';
|
||||||
import { Notifications } from '@mantine/notifications';
|
import { Notifications } from '@mantine/notifications';
|
||||||
import { ContextMenuProvider } from 'mantine-contextmenu';
|
import { ContextMenuProvider } from 'mantine-contextmenu';
|
||||||
|
import type { JSX } from 'react';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
|
import { AboutInvenTreeModal } from '../components/modals/AboutInvenTreeModal';
|
||||||
|
import { LicenseModal } from '../components/modals/LicenseModal';
|
||||||
|
import { QrModal } from '../components/modals/QrModal';
|
||||||
|
import { ServerInfoModal } from '../components/modals/ServerInfoModal';
|
||||||
import { useLocalState } from '../states/LocalState';
|
import { useLocalState } from '../states/LocalState';
|
||||||
import { LanguageContext } from './LanguageContext';
|
import { LanguageContext } from './LanguageContext';
|
||||||
import { colorSchema } from './colorSchema';
|
import { colorSchema } from './colorSchema';
|
||||||
|
|
||||||
// Lazy load the various modal dialogs - they are not needed immediately, and this can help to reduce the initial bundle size
|
|
||||||
const AboutInvenTreeModal = lazy(() =>
|
|
||||||
import('../components/modals/AboutInvenTreeModal').then((module) => ({
|
|
||||||
default: module.AboutInvenTreeModal
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
const LicenseModal = lazy(() =>
|
|
||||||
import('../components/modals/LicenseModal').then((module) => ({
|
|
||||||
default: module.LicenseModal
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
const QrModal = lazy(() =>
|
|
||||||
import('../components/modals/QrModal').then((module) => ({
|
|
||||||
default: module.QrModal
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
const ServerInfoModal = lazy(() =>
|
|
||||||
import('../components/modals/ServerInfoModal').then((module) => ({
|
|
||||||
default: module.ServerInfoModal
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
import { type JSX, lazy } from 'react';
|
|
||||||
|
|
||||||
export function ThemeContext({
|
export function ThemeContext({
|
||||||
children
|
children
|
||||||
}: Readonly<{ children: JSX.Element }>) {
|
}: Readonly<{ children: JSX.Element }>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user