Skip to content

Commit

Permalink
⚑️ perf: refactor Chat Layout to improve performance (lobehub#2339)
Browse files Browse the repository at this point in the history
* ♻️ refactor: Refactor Chat Layout

* βœ… test: Fix test

* πŸ› fix: Fix ci

* πŸ”§ chore: Rename workspace

* πŸ”§ chore: Revert sync style

* πŸ› fix: Fix review problem

* πŸ’„ style: Fix style

* πŸ”§ chore: Revert useInterceptingRoutes

* πŸ› fix: Fix review problem

* πŸ’„ style: Remove animation

* πŸ› fix: Fix panel

* πŸ› fix: Fix mobile style

* πŸ› fix: Fix Workspace Modal

* πŸ› fix: FIx ios keyboard scroll back

* πŸ› fix: Fix lint

* πŸ”§ chore: prepare to rebase

* πŸ› fix: Fix PWA

* πŸ› fix: Fix safearea
  • Loading branch information
canisminor1990 authored and TheNameIsNigel committed May 15, 2024
1 parent a0e7872 commit abf4e86
Show file tree
Hide file tree
Showing 127 changed files with 767 additions and 701 deletions.
27 changes: 0 additions & 27 deletions src/app/(main)/(mobile)/me/features/AvatarBanner.tsx

This file was deleted.

11 changes: 2 additions & 9 deletions src/app/(main)/(mobile)/me/features/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
'use client';

import { ActionIcon, MobileNavBar } from '@lobehub/ui';
import { useScroll } from 'ahooks';
import { useTheme } from 'antd-style';
import { Moon, Sun } from 'lucide-react';
import { memo } from 'react';

import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useUserStore } from '@/store/user';
import { mobileHeaderFixed } from '@/styles/mobileHeader';
import { mobileHeaderSticky } from '@/styles/mobileHeader';

const Header = memo(() => {
const theme = useTheme();
const scroll = useScroll(() => document.querySelector('#lobe-mobile-scroll-container'));
const switchThemeMode = useUserStore((s) => s.switchThemeMode);
const showBackground = (scroll as any)?.top > 44;

return (
<MobileNavBar
right={
<ActionIcon
color={showBackground ? undefined : theme.colorBgLayout}
icon={theme.isDarkMode ? Moon : Sun}
onClick={() => switchThemeMode(theme.isDarkMode ? 'light' : 'dark')}
size={MOBILE_HEADER_ICON_SIZE}
/>
}
style={{
...mobileHeaderFixed,
background: showBackground ? undefined : 'transparent',
}}
style={mobileHeaderSticky}
/>
);
});
Expand Down
29 changes: 0 additions & 29 deletions src/app/(main)/(mobile)/me/features/style.ts

This file was deleted.

13 changes: 1 addition & 12 deletions src/app/(main)/(mobile)/me/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@ import { Flexbox } from 'react-layout-kit';
import Divider from '@/components/Cell/Divider';
import SkeletonLoading from '@/components/SkeletonLoading';

import { useStyles } from './features/style';

const Loading = memo(() => {
const { styles } = useStyles();
return (
<>
<Flexbox align={'center'} className={styles.bannerBox} justify={'center'} />
<Flexbox
align={'center'}
className={styles.info}
gap={12}
horizontal
paddingBlock={12}
paddingInline={12}
>
<Flexbox align={'center'} gap={12} horizontal paddingBlock={12} paddingInline={12}>
<Skeleton.Avatar active shape={'circle'} size={48} />
<Skeleton.Button active block />
</Flexbox>
Expand Down
7 changes: 2 additions & 5 deletions src/app/(main)/(mobile)/me/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import DataStatistics from '@/features/User/DataStatistics';
import UserInfo from '@/features/User/UserInfo';
import { isMobileDevice } from '@/utils/responsive';

import AvatarBanner from './features/AvatarBanner';
import Cate from './features/Cate';
import ExtraCate from './features/ExtraCate';

Expand All @@ -18,10 +17,8 @@ const Page = () => {

return (
<>
<AvatarBanner>
<UserInfo />
<DataStatistics paddingInline={16} />
</AvatarBanner>
<UserInfo />
<DataStatistics paddingInline={12} style={{ paddingBottom: 6 }} />
<Divider />
<Cate />
<ExtraCate />
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/@nav/_layout/Mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Nav = memo(() => {
[t],
);

return <MobileTabBar activeKey={activeKey} className={styles.container} items={items} safeArea />;
return <MobileTabBar activeKey={activeKey} className={styles.container} items={items} />;
});

Nav.displayName = 'MobileNav';
Expand Down
6 changes: 5 additions & 1 deletion src/app/(main)/_layout/Mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import { usePathname } from 'next/navigation';
import { memo } from 'react';

import { useQuery } from '@/hooks/useQuery';

import { LayoutProps } from './type';

const MOBILE_IGNORE_NAV_ROUTES = ['/settings/', '/chat/'];

const Layout = memo(({ children, nav }: LayoutProps) => {
const { showMobileWorkspace } = useQuery();
const pathname = usePathname();
const hideNav = MOBILE_IGNORE_NAV_ROUTES.some((path) => pathname.startsWith(path));
const hideNav =
showMobileWorkspace || MOBILE_IGNORE_NAV_ROUTES.some((path) => pathname.startsWith(path));

return (
<>
Expand Down
19 changes: 0 additions & 19 deletions src/app/(main)/chat/(desktop)/features/Conversation.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/app/(main)/chat/(desktop)/index.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/(main)/chat/(mobile)/features/SessionList.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/app/(main)/chat/(mobile)/features/TopicList.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/app/(main)/chat/(mobile)/index.tsx

This file was deleted.

56 changes: 0 additions & 56 deletions src/app/(main)/chat/(mobile)/mobile/ChatHeader/index.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/app/(main)/chat/(mobile)/mobile/page.tsx

This file was deleted.

23 changes: 23 additions & 0 deletions src/app/(main)/chat/(workspace)/@conversation/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ChatHydration from '@/components/StoreHydration/ChatHydration';
import Conversation from '@/features/Conversation';
import { isMobileDevice } from '@/utils/responsive';

import DesktopChatInput from './features/ChatInput/Desktop';
import MobileChatInput from './features/ChatInput/Mobile';

const ChatConversation = () => {
const mobile = isMobileDevice();
const ChatInput = mobile ? MobileChatInput : DesktopChatInput;

return (
<>
<Conversation mobile={mobile} />
<ChatInput />
<ChatHydration />
</>
);
};

ChatConversation.displayName = 'ChatConversation';

export default ChatConversation;
Loading

0 comments on commit abf4e86

Please sign in to comment.