mirror of https://github.com/buster-so/buster.git
make global modal lazy
This commit is contained in:
parent
3deeb98bfc
commit
b82ba62db4
|
@ -0,0 +1,28 @@
|
||||||
|
import { useIsAnonymousUser } from '@/api/buster_rest/users/useGetUserInfo';
|
||||||
|
import { InvitePeopleModal } from '@/components/features/modals/InvitePeopleModal';
|
||||||
|
import { SupportModal } from '@/components/features/modals/SupportModal';
|
||||||
|
import { GlobalSearchModal } from '@/components/features/search/GlobalSearchModal';
|
||||||
|
import {
|
||||||
|
closeContactSupportModal,
|
||||||
|
useContactSupportModalStore,
|
||||||
|
} from '@/context/GlobalStore/useContactSupportModalStore';
|
||||||
|
import { closeInviteModal, useInviteModalStore } from '@/context/GlobalStore/useInviteModalStore';
|
||||||
|
|
||||||
|
const GlobalModals = () => {
|
||||||
|
const { openInviteModal } = useInviteModalStore();
|
||||||
|
const isAnonymousUser = useIsAnonymousUser();
|
||||||
|
const { formType } = useContactSupportModalStore();
|
||||||
|
|
||||||
|
if (isAnonymousUser) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<InvitePeopleModal open={openInviteModal} onClose={closeInviteModal} />
|
||||||
|
<SupportModal formType={formType} onClose={closeContactSupportModal} />
|
||||||
|
<GlobalSearchModal />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
GlobalModals.displayName = 'GlobalModals';
|
||||||
|
|
||||||
|
export default GlobalModals;
|
|
@ -1,6 +1,6 @@
|
||||||
import type { AssetType } from '@buster/server-shared/assets';
|
import type { AssetType } from '@buster/server-shared/assets';
|
||||||
import { Link, useNavigate } from '@tanstack/react-router';
|
import { Link, useNavigate } from '@tanstack/react-router';
|
||||||
import React, { useMemo } from 'react';
|
import React, { lazy, Suspense, useMemo } from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import {
|
import {
|
||||||
useIsAnonymousUser,
|
useIsAnonymousUser,
|
||||||
|
@ -31,23 +31,16 @@ import {
|
||||||
} from '@/components/ui/sidebar/create-sidebar-item';
|
} from '@/components/ui/sidebar/create-sidebar-item';
|
||||||
import { Sidebar } from '@/components/ui/sidebar/SidebarComponent';
|
import { Sidebar } from '@/components/ui/sidebar/SidebarComponent';
|
||||||
import { Tooltip } from '@/components/ui/tooltip/Tooltip';
|
import { Tooltip } from '@/components/ui/tooltip/Tooltip';
|
||||||
import {
|
import { toggleContactSupportModal } from '@/context/GlobalStore/useContactSupportModalStore';
|
||||||
closeContactSupportModal,
|
import { toggleInviteModal } from '@/context/GlobalStore/useInviteModalStore';
|
||||||
toggleContactSupportModal,
|
|
||||||
useContactSupportModalStore,
|
|
||||||
} from '@/context/GlobalStore/useContactSupportModalStore';
|
|
||||||
import {
|
|
||||||
closeInviteModal,
|
|
||||||
toggleInviteModal,
|
|
||||||
useInviteModalStore,
|
|
||||||
} from '@/context/GlobalStore/useInviteModalStore';
|
|
||||||
import { cn } from '@/lib/classMerge';
|
import { cn } from '@/lib/classMerge';
|
||||||
import { InvitePeopleModal } from '../../modals/InvitePeopleModal';
|
import { LazyErrorBoundary } from '../../global/LazyErrorBoundary';
|
||||||
import { SupportModal } from '../../modals/SupportModal';
|
import { toggleGlobalSearch } from '../../search/GlobalSearchModal';
|
||||||
import { GlobalSearchModal, toggleGlobalSearch } from '../../search/GlobalSearchModal';
|
|
||||||
import { SidebarUserFooter } from '../SidebarUserFooter';
|
import { SidebarUserFooter } from '../SidebarUserFooter';
|
||||||
import { useFavoriteSidebarPanel } from './useFavoritesSidebarPanel';
|
import { useFavoriteSidebarPanel } from './useFavoritesSidebarPanel';
|
||||||
|
|
||||||
|
const LazyGlobalModals = lazy(() => import('./PrimaryGlobalModals'));
|
||||||
|
|
||||||
const topItems: ISidebarList = createSidebarList({
|
const topItems: ISidebarList = createSidebarList({
|
||||||
id: 'top-items',
|
id: 'top-items',
|
||||||
items: [
|
items: [
|
||||||
|
@ -222,7 +215,11 @@ export const SidebarPrimary = React.memo(() => {
|
||||||
useCollapsible={isUserRegistered}
|
useCollapsible={isUserRegistered}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GlobalModals />
|
<LazyErrorBoundary>
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<LazyGlobalModals />
|
||||||
|
</Suspense>
|
||||||
|
</LazyErrorBoundary>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -270,20 +267,3 @@ const SidebarPrimaryHeader: React.FC<{ hideActions?: boolean }> = ({ hideActions
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const GlobalModals = () => {
|
|
||||||
const { openInviteModal } = useInviteModalStore();
|
|
||||||
const isAnonymousUser = useIsAnonymousUser();
|
|
||||||
const { formType } = useContactSupportModalStore();
|
|
||||||
|
|
||||||
if (isAnonymousUser) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<InvitePeopleModal open={openInviteModal} onClose={closeInviteModal} />
|
|
||||||
<SupportModal formType={formType} onClose={closeContactSupportModal} />
|
|
||||||
<GlobalSearchModal />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
GlobalModals.displayName = 'GlobalModals';
|
|
||||||
|
|
Loading…
Reference in New Issue