From 284f63cc3c196523cede18bc200b67a6575da66b Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Mon, 2 Sep 2024 21:02:17 +0530 Subject: [PATCH] fixed media hsm templates --- .../ChatMessages/AddAttachment/AddAttachment.tsx | 1 - .../Chat/ChatMessages/ChatInput/ChatInput.tsx | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/containers/Chat/ChatMessages/AddAttachment/AddAttachment.tsx b/src/containers/Chat/ChatMessages/AddAttachment/AddAttachment.tsx index 8a2d01b8d..00fb9380f 100644 --- a/src/containers/Chat/ChatMessages/AddAttachment/AddAttachment.tsx +++ b/src/containers/Chat/ChatMessages/AddAttachment/AddAttachment.tsx @@ -213,7 +213,6 @@ export const AddAttachment = ({ }} handleCancel={() => { setAttachment(false); - setAttachmentURL(''); setAttachmentAdded(false); }} diff --git a/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx b/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx index 051d0b9f3..3bef53a07 100644 --- a/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx +++ b/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx @@ -182,6 +182,17 @@ export const ChatInput = ({ // check for an empty message or message with just spaces if ((!message || /^\s*$/.test(message)) && !attachmentAdded) return; + //check if it has media if the template type is image + if ( + selectedTemplate && + selectedTemplate.isHsm && + selectedTemplate.type === 'IMAGE' && + !attachmentAdded + ) { + setAttachment(!attachment); + return; + } + // check if there is any attachment if (attachmentAdded) { createMediaMessage({ @@ -288,6 +299,7 @@ export const ChatInput = ({ const handleCancel = () => { resetAttachment(); resetVariable(); + setSelectedTemplate(undefined); editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined); editor.focus(); };