improve readability of map

This commit is contained in:
KDSBrowne 2019-08-12 16:11:59 +00:00
parent 0265dcdbb8
commit e35f1e4a8d

View File

@ -64,16 +64,16 @@ const Chat = (props) => {
let names = [];
names = typingUsers.map((user) => {
const currentChatPartner = chatID;
const { userId: typingUserId, isTypingTo, name } = user;
if (currentUserId === typingUserId) return null;
if (chatID !== isTypingTo) {
if (typingUserId === chatID) {
return currentUserId !== isTypingTo
? null : name;
}
return null;
let userNameTyping = null;
userNameTyping = currentUserId !== typingUserId ? name : userNameTyping;
const isPrivateMsg = currentChatPartner !== isTypingTo;
if (isPrivateMsg) {
const isMsgParticipant = typingUserId === currentChatPartner && currentUserId === isTypingTo;
userNameTyping = isMsgParticipant ? name : null;
}
return name;
return userNameTyping;
}).filter(e => e);
const renderIsTypingString = () => {