mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
💄 style: Open new topic by tap Just Chat again (#8426)
This commit is contained in:
+17
-2
@@ -6,6 +6,8 @@ import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
|
||||
import { INBOX_SESSION_ID } from '@/const/session';
|
||||
import { SESSION_CHAT_URL } from '@/const/url';
|
||||
import { useSwitchSession } from '@/hooks/useSwitchSession';
|
||||
import { getChatStoreState, useChatStore } from '@/store/chat';
|
||||
import { chatSelectors } from '@/store/chat/selectors';
|
||||
import { useServerConfigStore } from '@/store/serverConfig';
|
||||
import { useSessionStore } from '@/store/session';
|
||||
|
||||
@@ -17,13 +19,26 @@ const Inbox = memo(() => {
|
||||
const activeId = useSessionStore((s) => s.activeId);
|
||||
const switchSession = useSwitchSession();
|
||||
|
||||
const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
|
||||
|
||||
return (
|
||||
<Link
|
||||
aria-label={t('inbox.title')}
|
||||
href={SESSION_CHAT_URL(INBOX_SESSION_ID, mobile)}
|
||||
onClick={(e) => {
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
switchSession(INBOX_SESSION_ID);
|
||||
|
||||
if (activeId === INBOX_SESSION_ID && !mobile) {
|
||||
// If user tap the inbox again, open a new topic.
|
||||
// Only for desktop.
|
||||
const inboxMessages = chatSelectors.inboxActiveTopicMessages(getChatStoreState());
|
||||
|
||||
if (inboxMessages.length > 0) {
|
||||
await openNewTopicOrSaveTopic();
|
||||
}
|
||||
} else {
|
||||
switchSession(INBOX_SESSION_ID);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ListItem
|
||||
|
||||
@@ -201,6 +201,11 @@ const isSendButtonDisabledByMessage = (s: ChatStoreState) =>
|
||||
// 4. when the message is in RAG flow
|
||||
isInRAGFlow(s);
|
||||
|
||||
const inboxActiveTopicMessages = (state: ChatStoreState) => {
|
||||
const activeTopicId = state.activeTopicId;
|
||||
return state.messagesMap[messageMapKey(INBOX_SESSION_ID, activeTopicId)] || [];
|
||||
};
|
||||
|
||||
export const chatSelectors = {
|
||||
activeBaseChats,
|
||||
activeBaseChatsWithoutTool,
|
||||
@@ -213,6 +218,7 @@ export const chatSelectors = {
|
||||
getMessageById,
|
||||
getMessageByToolCallId,
|
||||
getTraceIdByMessageId,
|
||||
inboxActiveTopicMessages,
|
||||
isAIGenerating,
|
||||
isCreatingMessage,
|
||||
isCurrentChatLoaded,
|
||||
|
||||
Reference in New Issue
Block a user