fix message displaying when sending an img on chat

This commit is contained in:
cristhianzl 2024-06-17 17:34:54 -03:00
commit 929bac7036
5 changed files with 16 additions and 13 deletions

View file

@ -62,8 +62,8 @@ const handleFiles = (files, setFiles, currentFlowId, setErrorData) => {
});
return;
}
const uid = new ShortUniqueId({ length: 3 });
const id = uid();
const uid = new ShortUniqueId();
const id = uid.randomUUID(3);
const type = files[0].type.split("/")[0];
const blob = files[0];

View file

@ -28,8 +28,9 @@ export const useHandleFileChange = (setFiles, currentFlowId) => {
return;
}
const uid = new ShortUniqueId({ length: 10 }); // Increase the length to ensure uniqueness
const id = uid();
const uid = new ShortUniqueId();
const id = uid.randomUUID(10);
const type = file.type.split("/")[0];
const blob = file;

View file

@ -19,7 +19,7 @@ const useUpload = (uploadFile, currentFlowId, setFiles, lockChat) => {
if (items) {
for (let i = 0; i < items.length; i++) {
const type = items[0].type.split("/")[0];
const uid = new ShortUniqueId({ length: 3 });
const uid = new ShortUniqueId();
const blob = items[i].getAsFile();
if (blob) {
const fileExtension = blob.name.split(".").pop()?.toLowerCase();
@ -34,7 +34,7 @@ const useUpload = (uploadFile, currentFlowId, setFiles, lockChat) => {
});
return;
}
const id = uid();
const id = uid.randomUUID(3);
setFiles((prevFiles) => [
...prevFiles,
{ file: blob, loading: true, error: false, id, type },

View file

@ -200,8 +200,8 @@ export default function ChatMessage({
children,
...props
}) => {
if (children.length) {
if (children[0] === "▍") {
if (children?.length) {
if (children![0] === "▍") {
return (
<span className="form-modal-markdown-span">
@ -209,10 +209,9 @@ export default function ChatMessage({
);
}
children[0] = (children[0] as string).replace(
"`▍`",
"▍",
);
children![0] = (
children![0] as string
).replace("`▍`", "▍");
}
const match = /language-(\w+)/.exec(

View file

@ -77,10 +77,13 @@ export default function ChatView({
const is_ai =
sender === "Machine" || sender === null || sender === undefined;
return {
isSend: !is_ai,
message:
((message === "" || !message) && !stream_url) ? EMPTY_INPUT_SEND_MESSAGE : message,
(message === "" || !message) && !stream_url && files?.length === 0
? EMPTY_INPUT_SEND_MESSAGE
: message,
sender_name,
componentId: output.id,
stream_url: stream_url,