UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

30 lines (23 loc) 1.06 kB
import { useMemo } from 'react'; import urlJoin from 'url-join'; import { INBOX_SESSION_ID } from '@/const/session'; import { isDeprecatedEdition } from '@/const/version'; import { useIsMobile } from '@/hooks/useIsMobile'; import { useQueryRoute } from '@/hooks/useQueryRoute'; import { useAgentStore } from '@/store/agent'; import { ChatSettingsTabs, SettingsTabs } from '@/store/global/initialState'; import { useSessionStore } from '@/store/session'; export const useOpenChatSettings = (tab: ChatSettingsTabs = ChatSettingsTabs.Meta) => { const activeId = useSessionStore((s) => s.activeId); const isMobile = useIsMobile(); const router = useQueryRoute(); return useMemo(() => { if (isDeprecatedEdition && activeId === INBOX_SESSION_ID) { return () => router.push(urlJoin('/settings', SettingsTabs.Agent)); } if (isMobile) return () => router.push('/chat/settings', { query: { session: activeId } }); return () => { useAgentStore.setState({ showAgentSetting: true }); }; }, [activeId, router, tab, isMobile]); };