📕 fix: Update document Title based on appTitle and on "New Chat" (#1553)

This commit is contained in:
Danny Avila 2024-01-14 20:35:37 -05:00 committed by GitHub
parent 0f49642758
commit dfe45f80c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -92,6 +92,10 @@ const useNewConvo = (index = 0) => {
} }
if (conversation.conversationId === 'new' && !modelsData) { if (conversation.conversationId === 'new' && !modelsData) {
const appTitle = localStorage.getItem('appTitle');
if (appTitle) {
document.title = appTitle;
}
navigate('new'); navigate('new');
} }
}, },

View file

@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
import { import {
useGetConvoIdQuery, useGetConvoIdQuery,
useGetModelsQuery, useGetModelsQuery,
useGetStartupConfig,
useGetEndpointsQuery, useGetEndpointsQuery,
} from 'librechat-data-provider/react-query'; } from 'librechat-data-provider/react-query';
import type { TPreset } from 'librechat-data-provider'; import type { TPreset } from 'librechat-data-provider';
@ -18,6 +19,8 @@ export default function ChatRoute() {
useConfigOverride(); useConfigOverride();
const { conversationId } = useParams(); const { conversationId } = useParams();
const { data: startupConfig } = useGetStartupConfig();
const { conversation } = store.useCreateConversationAtom(index); const { conversation } = store.useCreateConversationAtom(index);
const modelsQueryEnabled = useRecoilValue(store.modelsQueryEnabled); const modelsQueryEnabled = useRecoilValue(store.modelsQueryEnabled);
const { isAuthenticated } = useAuthRedirect(); const { isAuthenticated } = useAuthRedirect();
@ -30,6 +33,13 @@ export default function ChatRoute() {
}); });
const endpointsQuery = useGetEndpointsQuery({ enabled: isAuthenticated && modelsQueryEnabled }); const endpointsQuery = useGetEndpointsQuery({ enabled: isAuthenticated && modelsQueryEnabled });
useEffect(() => {
if (startupConfig?.appTitle) {
document.title = startupConfig.appTitle;
localStorage.setItem('appTitle', startupConfig.appTitle);
}
}, [startupConfig]);
useEffect(() => { useEffect(() => {
if ( if (
conversationId === 'new' && conversationId === 'new' &&