forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor: refactor the chat conversation implement (lobehub#4689)
- Loading branch information
Showing
13 changed files
with
196 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/app/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use client'; | ||
|
||
import isEqual from 'fast-deep-equal'; | ||
import React, { memo } from 'react'; | ||
|
||
import { WELCOME_GUIDE_CHAT_ID } from '@/const/session'; | ||
import { VirtualizedList } from '@/features/Conversation'; | ||
import { useChatStore } from '@/store/chat'; | ||
import { chatSelectors } from '@/store/chat/selectors'; | ||
import { useSessionStore } from '@/store/session'; | ||
|
||
interface ListProps { | ||
mobile?: boolean; | ||
} | ||
|
||
const Content = memo<ListProps>(({ mobile }) => { | ||
const [activeTopicId, useFetchMessages] = useChatStore((s) => [ | ||
s.activeTopicId, | ||
s.useFetchMessages, | ||
]); | ||
|
||
const [sessionId] = useSessionStore((s) => [s.activeId]); | ||
useFetchMessages(sessionId, activeTopicId); | ||
|
||
const data = useChatStore((s) => { | ||
const showInboxWelcome = chatSelectors.showInboxWelcome(s); | ||
if (showInboxWelcome) return [WELCOME_GUIDE_CHAT_ID]; | ||
|
||
return chatSelectors.currentChatIDsWithGuideMessage(s); | ||
}, isEqual); | ||
|
||
return <VirtualizedList dataSource={data} mobile={mobile} />; | ||
}); | ||
|
||
export default Content; |
28 changes: 28 additions & 0 deletions
28
src/app/(main)/chat/(workspace)/@conversation/features/ChatList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Suspense, lazy } from 'react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import { SkeletonList } from '@/features/Conversation'; | ||
|
||
const Content = lazy(() => import('./Content')); | ||
|
||
interface ChatListProps { | ||
mobile?: boolean; | ||
} | ||
|
||
const ChatList = ({ mobile }: ChatListProps) => ( | ||
<Flexbox | ||
flex={1} | ||
style={{ | ||
overflowX: 'hidden', | ||
overflowY: 'auto', | ||
position: 'relative', | ||
}} | ||
width={'100%'} | ||
> | ||
<Suspense fallback={<SkeletonList mobile={mobile} />}> | ||
<Content mobile={mobile} /> | ||
</Suspense> | ||
</Flexbox> | ||
); | ||
|
||
export default ChatList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type { ActionKeys } from './ActionBar/config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.