mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 01:49:51 +08:00
fix(core): adjust suspense loading for some components (#6088)
Adjust setting & user info popover suspense to make them a little bit more responsive
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { Loading } from '@affine/component';
|
||||||
import { WorkspaceDetailSkeleton } from '@affine/component/setting-components';
|
import { WorkspaceDetailSkeleton } from '@affine/component/setting-components';
|
||||||
import { Modal, type ModalProps } from '@affine/component/ui/modal';
|
import { Modal, type ModalProps } from '@affine/component/ui/modal';
|
||||||
import {
|
import {
|
||||||
@@ -36,7 +37,15 @@ export interface SettingProps extends ModalProps {
|
|||||||
const isGeneralSetting = (key: string): key is GeneralSettingKey =>
|
const isGeneralSetting = (key: string): key is GeneralSettingKey =>
|
||||||
GeneralSettingKeys.includes(key as GeneralSettingKey);
|
GeneralSettingKeys.includes(key as GeneralSettingKey);
|
||||||
|
|
||||||
export const SettingModal = ({
|
const CenteredLoading = () => {
|
||||||
|
return (
|
||||||
|
<div className={style.centeredLoading}>
|
||||||
|
<Loading size={24} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const SettingModalInner = ({
|
||||||
activeTab = 'appearance',
|
activeTab = 'appearance',
|
||||||
workspaceMetadata = null,
|
workspaceMetadata = null,
|
||||||
onSettingClick,
|
onSettingClick,
|
||||||
@@ -95,27 +104,12 @@ export const SettingModal = ({
|
|||||||
}, [setOpenStarAFFiNEModal]);
|
}, [setOpenStarAFFiNEModal]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<>
|
||||||
width={1080}
|
|
||||||
height={760}
|
|
||||||
contentOptions={{
|
|
||||||
['data-testid' as string]: 'setting-modal',
|
|
||||||
style: {
|
|
||||||
maxHeight: '85vh',
|
|
||||||
maxWidth: '70vw',
|
|
||||||
padding: 0,
|
|
||||||
overflow: 'hidden',
|
|
||||||
display: 'flex',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
{...modalProps}
|
|
||||||
>
|
|
||||||
<SettingSidebar
|
<SettingSidebar
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
onTabChange={onTabChange}
|
onTabChange={onTabChange}
|
||||||
selectedWorkspaceId={workspaceMetadata?.id ?? null}
|
selectedWorkspaceId={workspaceMetadata?.id ?? null}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-testid="setting-modal-content"
|
data-testid="setting-modal-content"
|
||||||
className={style.wrapper}
|
className={style.wrapper}
|
||||||
@@ -161,6 +155,40 @@ export const SettingModal = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SettingModal = ({
|
||||||
|
activeTab = 'appearance',
|
||||||
|
workspaceMetadata = null,
|
||||||
|
onSettingClick,
|
||||||
|
...modalProps
|
||||||
|
}: SettingProps) => {
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
width={1080}
|
||||||
|
height={760}
|
||||||
|
contentOptions={{
|
||||||
|
['data-testid' as string]: 'setting-modal',
|
||||||
|
style: {
|
||||||
|
maxHeight: '85vh',
|
||||||
|
maxWidth: '70vw',
|
||||||
|
padding: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
display: 'flex',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
{...modalProps}
|
||||||
|
>
|
||||||
|
<Suspense fallback={<CenteredLoading />}>
|
||||||
|
<SettingModalInner
|
||||||
|
activeTab={activeTab}
|
||||||
|
workspaceMetadata={workspaceMetadata}
|
||||||
|
onSettingClick={onSettingClick}
|
||||||
|
{...modalProps}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,3 +51,11 @@ export const link = style({
|
|||||||
color: cssVar('linkColor'),
|
color: cssVar('linkColor'),
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const centeredLoading = style({
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
|
});
|
||||||
|
|||||||
+7
@@ -49,3 +49,10 @@ export const signInTextSecondary = style({
|
|||||||
export const menuItem = style({
|
export const menuItem = style({
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
});
|
});
|
||||||
|
export const loadingWrapper = style({
|
||||||
|
height: 42,
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
});
|
||||||
|
|||||||
+24
-5
@@ -1,3 +1,4 @@
|
|||||||
|
import { Loading } from '@affine/component';
|
||||||
import { Divider } from '@affine/component/ui/divider';
|
import { Divider } from '@affine/component/ui/divider';
|
||||||
import { MenuItem } from '@affine/component/ui/menu';
|
import { MenuItem } from '@affine/component/ui/menu';
|
||||||
import { useSession } from '@affine/core/hooks/affine/use-current-user';
|
import { useSession } from '@affine/core/hooks/affine/use-current-user';
|
||||||
@@ -8,7 +9,7 @@ import { WorkspaceManager } from '@toeverything/infra';
|
|||||||
import { useService } from '@toeverything/infra/di';
|
import { useService } from '@toeverything/infra/di';
|
||||||
import { useLiveData } from '@toeverything/infra/livedata';
|
import { useLiveData } from '@toeverything/infra/livedata';
|
||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { Suspense, useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
authAtom,
|
authAtom,
|
||||||
@@ -62,11 +63,21 @@ const SignInItem = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UserWithWorkspaceList = ({
|
const UserWithWorkspaceListLoading = () => {
|
||||||
onEventEnd,
|
return (
|
||||||
}: {
|
<div className={styles.loadingWrapper}>
|
||||||
|
<Loading size={24} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface UserWithWorkspaceListProps {
|
||||||
onEventEnd?: () => void;
|
onEventEnd?: () => void;
|
||||||
}) => {
|
}
|
||||||
|
|
||||||
|
const UserWithWorkspaceListInner = ({
|
||||||
|
onEventEnd,
|
||||||
|
}: UserWithWorkspaceListProps) => {
|
||||||
const { user, status } = useSession();
|
const { user, status } = useSession();
|
||||||
|
|
||||||
const isAuthenticated = status === 'authenticated';
|
const isAuthenticated = status === 'authenticated';
|
||||||
@@ -139,3 +150,11 @@ export const UserWithWorkspaceList = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const UserWithWorkspaceList = (props: UserWithWorkspaceListProps) => {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<UserWithWorkspaceListLoading />}>
|
||||||
|
<UserWithWorkspaceListInner {...props} />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user