mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 19:00:13 +01:00
* wip: general setup * added: translations for font-size * fix: prompts related linter errors and add theming * wip: font size selector * refactor: Update FontSizeSelector options display property * refactor: adjust Intersection Observer threshold and debounce rate * feat: Update selectedPrompt type in PromptForm to be optional * feat: dynamic font size * refactor: Update message font size in navigation bar * refactor: Update code analyze block styling * refactor: ProgressText dynamic font size * refactor: move FontSizeSelector component to Chat from General settings * fix: HoverButtons styling for better visibility * refactor: Update HoverButtons styling for better visibility --------- Co-authored-by: kraken <solodarken@gmail.com>
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import React from 'react';
|
|
import { useMessageProcess } from '~/hooks';
|
|
import type { TMessageProps } from '~/common';
|
|
import MessageRender from './ui/MessageRender';
|
|
// eslint-disable-next-line import/no-cycle
|
|
import MultiMessage from './MultiMessage';
|
|
|
|
const MessageContainer = React.memo(
|
|
({ handleScroll, children }: { handleScroll: () => void; children: React.ReactNode }) => {
|
|
return (
|
|
<div
|
|
className="text-token-text-primary w-full border-0 bg-transparent dark:border-0 dark:bg-transparent"
|
|
onWheel={handleScroll}
|
|
onTouchMove={handleScroll}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
},
|
|
);
|
|
|
|
export default function Message(props: TMessageProps) {
|
|
const {
|
|
showSibling,
|
|
conversation,
|
|
handleScroll,
|
|
siblingMessage,
|
|
latestMultiMessage,
|
|
isSubmittingFamily,
|
|
} = useMessageProcess({ message: props.message });
|
|
const { message, currentEditId, setCurrentEditId } = props;
|
|
|
|
if (!message) {
|
|
return null;
|
|
}
|
|
|
|
const { children, messageId = null } = message ?? {};
|
|
|
|
return (
|
|
<>
|
|
<MessageContainer handleScroll={handleScroll}>
|
|
{showSibling ? (
|
|
<div className="m-auto my-2 flex justify-center p-4 py-2 md:gap-6">
|
|
<div className="flex w-full flex-row flex-wrap justify-between gap-1 md:max-w-5xl md:flex-nowrap md:gap-2 lg:max-w-5xl xl:max-w-6xl">
|
|
<MessageRender
|
|
{...props}
|
|
message={message}
|
|
isSubmittingFamily={isSubmittingFamily}
|
|
isCard
|
|
/>
|
|
<MessageRender
|
|
{...props}
|
|
isMultiMessage
|
|
isCard
|
|
message={siblingMessage ?? latestMultiMessage ?? undefined}
|
|
isSubmittingFamily={isSubmittingFamily}
|
|
/>
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<div className="m-auto justify-center p-4 py-2 md:gap-6 ">
|
|
<MessageRender {...props} />
|
|
</div>
|
|
)}
|
|
</MessageContainer>
|
|
<MultiMessage
|
|
key={messageId}
|
|
messageId={messageId}
|
|
conversation={conversation}
|
|
messagesTree={children ?? []}
|
|
currentEditId={currentEditId}
|
|
setCurrentEditId={setCurrentEditId}
|
|
/>
|
|
</>
|
|
);
|
|
}
|