feat: Show cc from last email on reply editor (#3983)
* Adds last emails to reply editor * Fixes bug in reply box * Adds test cases * Prevents private notes having cc bcc data * Prevents private notes having cc bcc data * Init reply head with values * fix broken tests Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Fayaz Ahmed <15716057+fayazara@users.noreply.github.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1de18391b4
commit
eee89bf0d8
@@ -1,4 +1,5 @@
|
||||
import authAPI from '../../../api/auth';
|
||||
import { MESSAGE_TYPE } from 'shared/constants/messages';
|
||||
import { applyPageFilters } from './helpers';
|
||||
|
||||
export const getSelectedChatConversation = ({
|
||||
@@ -19,6 +20,26 @@ const getters = {
|
||||
);
|
||||
return selectedChat || {};
|
||||
},
|
||||
getLastEmailInSelectedChat: (stage, _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;
|
||||
});
|
||||
|
||||
return lastEmail;
|
||||
},
|
||||
getMineChats: _state => activeFilters => {
|
||||
const currentUserID = authAPI.getCurrentUser().id;
|
||||
|
||||
|
||||
@@ -131,4 +131,34 @@ describe('#getters', () => {
|
||||
expect(getters.getAppliedConversationFilters(state)).toEqual(filtersList);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getLastEmailInSelectedChat', () => {
|
||||
it('Returns cc in last email', () => {
|
||||
const state = {};
|
||||
const getSelectedChat = {
|
||||
messages: [
|
||||
{
|
||||
message_type: 1,
|
||||
content_attributes: {
|
||||
email: {
|
||||
from: 'why@how.my',
|
||||
cc: ['nithin@me.co', 'we@who.why'],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(
|
||||
getters.getLastEmailInSelectedChat(state, { getSelectedChat })
|
||||
).toEqual({
|
||||
message_type: 1,
|
||||
content_attributes: {
|
||||
email: {
|
||||
from: 'why@how.my',
|
||||
cc: ['nithin@me.co', 'we@who.why'],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user