fix: inconsistent reply box cc update (#10799)
This PR target two issues ### CC & BCC not updated correctly When moving from one conversation to another, the store may not have the list of all the messages. A fetch is subsequently made to get the messages. However, this update does not trigger the `currentChat` watcher. This PR fixes it by adding a new watcher on `currentChat.messages`. We also update the `setCCAndToEmailsFromLastChat` method to reset the `cc`, `bcc` and `to` fields if the last email is not found. This ensures that the data is not carried forward from a previous email Fixes: https://github.com/chatwoot/chatwoot/issues/10477 ### To address are not added correctly to the `CC` If the `to` address of a previous email has multiple recipient, there was no case to add them to the CC. Fixes: https://github.com/chatwoot/chatwoot/issues/8925 --- Depends on: https://github.com/chatwoot/utils/pull/41
This commit is contained in:
@@ -27,18 +27,12 @@ const getters = {
|
||||
const selectedChat = _getters.getSelectedChat;
|
||||
const { messages = [] } = selectedChat;
|
||||
const lastEmail = [...messages].reverse().find(message => {
|
||||
const {
|
||||
content_attributes: contentAttributes = {},
|
||||
message_type: messageType,
|
||||
} = message;
|
||||
const { email = {} } = contentAttributes;
|
||||
const isIncomingOrOutgoing =
|
||||
messageType === MESSAGE_TYPE.OUTGOING ||
|
||||
messageType === MESSAGE_TYPE.INCOMING;
|
||||
if (email.from && isIncomingOrOutgoing) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
const { message_type: messageType } = message;
|
||||
if (message.private) return false;
|
||||
|
||||
return [MESSAGE_TYPE.OUTGOING, MESSAGE_TYPE.INCOMING].includes(
|
||||
messageType
|
||||
);
|
||||
});
|
||||
|
||||
return lastEmail;
|
||||
|
||||
Reference in New Issue
Block a user