diff --git a/src/components/UI/Form/EmojiInput/Editor.tsx b/src/components/UI/Form/EmojiInput/Editor.tsx index 1047dfcf2..a2f20dbcd 100644 --- a/src/components/UI/Form/EmojiInput/Editor.tsx +++ b/src/components/UI/Form/EmojiInput/Editor.tsx @@ -48,7 +48,7 @@ export const Editor = ({ const [editor] = useLexicalComposerContext(); useEffect(() => { - if (field.value && !editorState && isEditing) { + if ((field.value || field.value === '') && !editorState && isEditing) { setInitialState(editor, field.value); } }, [field.value]); diff --git a/src/containers/Chat/ChatMessages/ChatMessage/ChatMessage.tsx b/src/containers/Chat/ChatMessages/ChatMessage/ChatMessage.tsx index 98f2e3e4a..df143aff1 100644 --- a/src/containers/Chat/ChatMessages/ChatMessage/ChatMessage.tsx +++ b/src/containers/Chat/ChatMessages/ChatMessage/ChatMessage.tsx @@ -129,10 +129,18 @@ export const ChatMessage = ({ ); } else if (Object.prototype.hasOwnProperty.call(messageError, 'message')) { messageErrorStatus = parseTextMethod(messageError.message); + let messageStatus: any; + + if (Object.prototype.hasOwnProperty.call(messageErrorStatus, 'message')) { + messageStatus = messageErrorStatus.message; + } else { + messageStatus = messageErrorStatus[0]; + } + tooltipTitle = ( <> {tooltipTitle} -
{messageErrorStatus[0]}
+
{messageStatus}
); } else if (Object.keys(messageError).length !== 0) { diff --git a/src/containers/InteractiveMessage/InteractiveMessage.tsx b/src/containers/InteractiveMessage/InteractiveMessage.tsx index 4615ea188..b992f876a 100644 --- a/src/containers/InteractiveMessage/InteractiveMessage.tsx +++ b/src/containers/InteractiveMessage/InteractiveMessage.tsx @@ -166,7 +166,7 @@ export const InteractiveMessage = () => { setTitle(data.title); setFooter(data.footer || ''); - setBody(data.body); + setBody(data.body || ''); setEditorState(null); setTemplateType(typeValue); setTemplateTypeField(templateTypeOptions.find((option) => option.id === typeValue)); @@ -236,7 +236,8 @@ export const InteractiveMessage = () => { setTitle(titleText); setFooter(data.footer || ''); - setBody(data.body); + setBody(data.body || ''); + setEditorState(null); setTemplateType(typeValue); setTemplateTypeField(templateTypeOptions.find((option) => option.id === typeValue)); setTimeout(() => setTemplateButtons(data.templateButtons), 100); diff --git a/src/containers/Template/Form/Template.tsx b/src/containers/Template/Form/Template.tsx index aae4b2bc7..89400c36c 100644 --- a/src/containers/Template/Form/Template.tsx +++ b/src/containers/Template/Form/Template.tsx @@ -282,7 +282,8 @@ const Template = ({ setIsActive(isActiveValue); if (typeof bodyValue === 'string') { - setBody(bodyValue); + setBody(bodyValue || ''); + setEditorState(null); } if (exampleValue) { @@ -322,7 +323,7 @@ const Template = ({ ) { const content = translationsCopy[currentLanguage]; setLabel(content.label); - setBody(content.body); + setBody(content.body || ''); setEditorState(null); } setTranslations(translationsValue); @@ -357,7 +358,8 @@ const Template = ({ setLabel(labelValue); if (typeof bodyValue === 'string') { - setBody(bodyValue); + setBody(bodyValue || ''); + setEditorState(null); } if (typeValue && typeValue !== 'TEXT') { diff --git a/src/containers/WaGroups/GroupMessageSubscription.tsx b/src/containers/WaGroups/GroupMessageSubscription.tsx index eeff6a6e2..72f8ecf71 100644 --- a/src/containers/WaGroups/GroupMessageSubscription.tsx +++ b/src/containers/WaGroups/GroupMessageSubscription.tsx @@ -12,6 +12,7 @@ import { randomIntFromInterval, addLogs } from 'common/utils'; import { GROUP_SEARCH_QUERY } from 'graphql/queries/WaGroups'; import { SENT_MESSAGE_WA_GROUP_COLLECTION, + UPDATE_WA_MESSAGE_STATUS, WA_MESSAGE_RECEIVED_SUBSCRIPTION, WA_MESSAGE_SENT_SUBSCRIPTION, } from 'graphql/subscriptions/Groups'; @@ -219,6 +220,14 @@ export const GroupMessageSubscription = ({ setDataLoaded }: GroupMessageProps) = updateQuery: (prev, { subscriptionData }) => updateConversations(prev, subscriptionData, 'SENT'), }); + + subscribeToMore({ + document: UPDATE_WA_MESSAGE_STATUS, + variables: subscriptionVariables, + onError: (error) => console.log(error), + updateQuery: (prev, { subscriptionData }) => + updateConversations(prev, subscriptionData, 'STATUS'), + }); } }, [subscribeToMore]); diff --git a/src/graphql/subscriptions/Groups.ts b/src/graphql/subscriptions/Groups.ts index 5f7f7c6db..9ced03d8d 100644 --- a/src/graphql/subscriptions/Groups.ts +++ b/src/graphql/subscriptions/Groups.ts @@ -118,3 +118,16 @@ export const SENT_MESSAGE_WA_GROUP_COLLECTION = gql` } } `; + +export const UPDATE_WA_MESSAGE_STATUS = gql` + subscription UpdateWaMessageStatus($organizationId: ID!) { + updateWaMessageStatus(organizationId: $organizationId) { + id + messageNumber + errors + waGroup { + id + } + } + } +`; diff --git a/src/services/SubscriptionService.ts b/src/services/SubscriptionService.ts index 326ad0052..f638148c3 100644 --- a/src/services/SubscriptionService.ts +++ b/src/services/SubscriptionService.ts @@ -78,8 +78,12 @@ export const getSubscriptionDetails = (action: string, subscriptionData: any, gr break; case 'STATUS': // set the receiver contact id - messageStatusData = subscriptionData.data.updateMessageStatus; - entityId = subscriptionData.data.updateMessageStatus.receiver.id; + messageStatusData = groups + ? subscriptionData.data.updateWaMessageStatus + : subscriptionData.data.updateMessageStatus; + entityId = groups + ? subscriptionData.data.updateWaMessageStatus.waGroup.id + : subscriptionData.data.updateMessageStatus.receiver.id; break; default: break;