mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* BIG UI UPDATE * fix: search bar, dialog template, new chat icon, convo icon and delete/rename button * moved some color config and a lot of files * small text fixes and tailwind config refactor * Update localization and UI styles * Update styles and add user-select:none to Tooltip component * Update mobile.css styles for navigation mask and background color * Update component imports and styles * Update DeleteButton imports and references * Update UI components * Update tooltip delay duration * Fix styling and update text in various components * fixed assistant style * minor style fixes * revert: removed CreationHeader & CreationPanel * style: match new styling for SidePanel * style: match bg-gray-800 to ChatGPT (#212121) * style: remove slate for gray where applicable to match new light theme --------- Co-authored-by: Danny Avila <messagedaniel@protonmail.com>
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
import { useState } from 'react';
|
|
import type { ReactNode } from 'react';
|
|
import type { TMessage } from 'librechat-data-provider';
|
|
import ScrollToBottom from '~/components/Messages/ScrollToBottom';
|
|
import { useScreenshot, useMessageScrolling } from '~/hooks';
|
|
import { CSSTransition } from 'react-transition-group';
|
|
import MultiMessage from './MultiMessage';
|
|
|
|
export default function MessagesView({
|
|
messagesTree: _messagesTree,
|
|
Header,
|
|
}: {
|
|
messagesTree?: TMessage[] | null;
|
|
Header?: ReactNode;
|
|
}) {
|
|
const { screenshotTargetRef } = useScreenshot();
|
|
const [currentEditId, setCurrentEditId] = useState<number | string | null>(-1);
|
|
|
|
const {
|
|
conversation,
|
|
scrollableRef,
|
|
messagesEndRef,
|
|
showScrollButton,
|
|
handleSmoothToRef,
|
|
debouncedHandleScroll,
|
|
} = useMessageScrolling(_messagesTree);
|
|
|
|
const { conversationId } = conversation ?? {};
|
|
|
|
return (
|
|
<div className="flex-1 overflow-hidden overflow-y-auto">
|
|
<div className="dark:gpt-dark-gray relative h-full">
|
|
<div
|
|
onScroll={debouncedHandleScroll}
|
|
ref={scrollableRef}
|
|
style={{
|
|
height: '100%',
|
|
overflowY: 'auto',
|
|
width: '100%',
|
|
}}
|
|
>
|
|
<div className="flex flex-col pb-9 text-sm dark:bg-transparent">
|
|
{(_messagesTree && _messagesTree?.length == 0) || _messagesTree === null ? (
|
|
<div className="flex w-full items-center justify-center gap-1 bg-gray-50 p-3 text-sm text-gray-500 dark:border-gray-800/50 dark:bg-gray-800 dark:text-gray-300">
|
|
Nothing found
|
|
</div>
|
|
) : (
|
|
<>
|
|
{Header && Header}
|
|
<div ref={screenshotTargetRef}>
|
|
<MultiMessage
|
|
key={conversationId} // avoid internal state mixture
|
|
messagesTree={_messagesTree}
|
|
messageId={conversationId ?? null}
|
|
setCurrentEditId={setCurrentEditId}
|
|
currentEditId={currentEditId ?? null}
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
<div
|
|
className="dark:gpt-dark-gray group h-0 w-full flex-shrink-0 dark:border-gray-800/50"
|
|
ref={messagesEndRef}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<CSSTransition
|
|
in={showScrollButton}
|
|
timeout={400}
|
|
classNames="scroll-down"
|
|
unmountOnExit={false}
|
|
// appear
|
|
>
|
|
{() => showScrollButton && <ScrollToBottom scrollHandler={handleSmoothToRef} />}
|
|
</CSSTransition>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|