Skip to content

Commit

Permalink
🔧 fix: Ensure ShareView document title is configured (#3336)
Browse files Browse the repository at this point in the history
* 🔧 fix: ensure ShareView document title is configured

* chore: import order

---------

Co-authored-by: Danny Avila <danacordially@gmail.com>
  • Loading branch information
arthurian and danny-avila authored Jul 27, 2024
1 parent 18fd8f1 commit 14eff23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions client/src/components/Share/ShareView.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import { memo } from 'react';
import { useParams } from 'react-router-dom';
import { useGetSharedMessages } from 'librechat-data-provider/react-query';
import { useGetSharedMessages, useGetStartupConfig } from 'librechat-data-provider/react-query';
import { useLocalize, useDocumentTitle } from '~/hooks';
import { ShareContext } from '~/Providers';
import { Spinner } from '~/components/svg';
import MessagesView from './MessagesView';
import { useLocalize } from '~/hooks';
import { buildTree } from '~/utils';
import Footer from '../Chat/Footer';

function SharedView() {
const localize = useLocalize();
const { data: config } = useGetStartupConfig();
const { shareId } = useParams();
const { data, isLoading } = useGetSharedMessages(shareId ?? '');
const dataTree = data && buildTree({ messages: data.messages });
const messagesTree = dataTree?.length === 0 ? null : dataTree ?? null;

// configure document title
let docTitle = '';
if (config?.appTitle && data?.title) {
docTitle = `${data?.title} | ${config.appTitle}`;
} else {
docTitle = data?.title || config?.appTitle || document.title;
}

useDocumentTitle(docTitle);

return (
<ShareContext.Provider value={{ isSharedConvo: true }}>
<div
Expand Down
1 change: 1 addition & 0 deletions client/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ export { default as useOnClickOutside } from './useOnClickOutside';
export { default as useSpeechToText } from './Input/useSpeechToText';
export { default as useTextToSpeech } from './Input/useTextToSpeech';
export { default as useGenerationsByLatest } from './useGenerationsByLatest';
export { default as useDocumentTitle } from './useDocumentTitle';

0 comments on commit 14eff23

Please sign in to comment.