style: loading indicator appears in ai reply
This commit is contained in:
parent
0180937262
commit
69e26c39a1
@ -34,23 +34,16 @@ const InputToolbar: React.FC = () => {
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="h-6 space-x-5">
|
||||
{currentConvoState?.error && (
|
||||
<div className="flex flex-row justify-center">
|
||||
<span className="mx-5 my-2 text-red-500 text-sm">
|
||||
{currentConvoState?.error?.toString()}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-center gap-2 my-5">
|
||||
{/* TODO: take loading out of input toolbar and into response */}
|
||||
<div className="h-6 space-x-5">
|
||||
{currentConvoState?.waitingForResponse === true && (
|
||||
<div className="ml-1 my-2" key="indicator">
|
||||
<LoadingIndicator />
|
||||
</div>
|
||||
)}
|
||||
{!currentConvoState?.waitingForResponse &&
|
||||
currentConvoState?.error && (
|
||||
<div className="flex flex-row justify-center">
|
||||
<span className="mx-5 my-2 text-red-500 text-sm">
|
||||
{currentConvoState?.error?.toString()}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{/* <SecondaryButton title="Regenerate" onClick={onRegenerateClick} /> */}
|
||||
<SecondaryButton
|
||||
onClick={onNewConversationClick}
|
||||
|
||||
@ -4,6 +4,7 @@ import { TextCode } from "../TextCode";
|
||||
import { getMessageCode } from "@/_utils/message";
|
||||
import Image from "next/image";
|
||||
import { MessageSenderType } from "@/_models/ChatMessage";
|
||||
import LoadingIndicator from "../LoadingIndicator";
|
||||
|
||||
type Props = {
|
||||
avatarUrl: string;
|
||||
@ -13,6 +14,17 @@ type Props = {
|
||||
text?: string;
|
||||
};
|
||||
|
||||
const renderMessageCode = (text: string) => {
|
||||
return getMessageCode(text).map((item, i) => (
|
||||
<div className="flex gap-1 flex-col" key={i}>
|
||||
<p className="leading-[20px] whitespace-break-spaces text-sm font-normal dark:text-[#d1d5db]">
|
||||
{item.text}
|
||||
</p>
|
||||
{item.code.trim().length > 0 && <TextCode text={item.code} />}
|
||||
</div>
|
||||
));
|
||||
};
|
||||
|
||||
const SimpleTextMessage: React.FC<Props> = ({
|
||||
senderName,
|
||||
createdAt,
|
||||
@ -43,15 +55,10 @@ const SimpleTextMessage: React.FC<Props> = ({
|
||||
{displayDate(createdAt)}
|
||||
</div>
|
||||
</div>
|
||||
{text.includes("```") ? (
|
||||
getMessageCode(text).map((item, i) => (
|
||||
<div className="flex gap-1 flex-col" key={i}>
|
||||
<p className="leading-[20px] whitespace-break-spaces text-sm font-normal dark:text-[#d1d5db]">
|
||||
{item.text}
|
||||
</p>
|
||||
{item.code.trim().length > 0 && <TextCode text={item.code} />}
|
||||
</div>
|
||||
))
|
||||
{text === "" ? (
|
||||
<LoadingIndicator />
|
||||
) : text.includes("```") ? (
|
||||
renderMessageCode(text)
|
||||
) : (
|
||||
<span className="text-sm leading-loose font-normal">{text}</span>
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user