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; return;
} }
const uid = new ShortUniqueId({ length: 3 }); const uid = new ShortUniqueId();
const id = uid(); const id = uid.randomUUID(3);
const type = files[0].type.split("/")[0]; const type = files[0].type.split("/")[0];
const blob = files[0]; const blob = files[0];

View file

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

View file

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

View file

@ -200,8 +200,8 @@ export default function ChatMessage({
children, children,
...props ...props
}) => { }) => {
if (children.length) { if (children?.length) {
if (children[0] === "▍") { if (children![0] === "▍") {
return ( return (
<span className="form-modal-markdown-span"> <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( const match = /language-(\w+)/.exec(

View file

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