Skip to content

Commit

Permalink
Merge pull request #3052 from glific/fix/media-hsm
Browse files Browse the repository at this point in the history
Fix for media hsm templates
  • Loading branch information
kurund authored Sep 3, 2024
2 parents 7584cb0 + b6d21eb commit 97bfd7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export const AddAttachment = ({
}}
handleCancel={() => {
setAttachment(false);

setAttachmentURL('');
setAttachmentAdded(false);
}}
Expand Down
12 changes: 12 additions & 0 deletions src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== 'TEXT' &&
!attachmentAdded
) {
setAttachment(!attachment);
return;
}

// check if there is any attachment
if (attachmentAdded) {
createMediaMessage({
Expand Down Expand Up @@ -288,6 +299,7 @@ export const ChatInput = ({
const handleCancel = () => {
resetAttachment();
resetVariable();
setSelectedTemplate(undefined);
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
editor.focus();
};
Expand Down

0 comments on commit 97bfd7f

Please sign in to comment.