From 284f63cc3c196523cede18bc200b67a6575da66b Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Mon, 2 Sep 2024 21:02:17 +0530 Subject: [PATCH 1/2] 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(); }; From 7bf8288de016f761eeb2ae4b532e5bcaac45a195 Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Tue, 3 Sep 2024 23:30:18 +0530 Subject: [PATCH 2/2] changed template type from image to text --- src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx b/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx index 3bef53a07..e9b67e3c9 100644 --- a/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx +++ b/src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx @@ -186,7 +186,7 @@ export const ChatInput = ({ if ( selectedTemplate && selectedTemplate.isHsm && - selectedTemplate.type === 'IMAGE' && + selectedTemplate.type !== 'TEXT' && !attachmentAdded ) { setAttachment(!attachment);