chore: Refactor widget (#5621)
This commit is contained in:
@@ -32,7 +32,7 @@ export const getters = {
|
||||
},
|
||||
getUnreadMessageCount: _state => {
|
||||
const { userLastSeenAt } = _state.meta;
|
||||
const count = Object.values(_state.conversations).filter(chat => {
|
||||
return Object.values(_state.conversations).filter(chat => {
|
||||
const { created_at: createdAt, message_type: messageType } = chat;
|
||||
const isOutGoing = messageType === MESSAGE_TYPE.OUTGOING;
|
||||
const hasNotSeen = userLastSeenAt
|
||||
@@ -40,7 +40,6 @@ export const getters = {
|
||||
: true;
|
||||
return hasNotSeen && isOutGoing;
|
||||
}).length;
|
||||
return count;
|
||||
},
|
||||
getUnreadTextMessages: (_state, _getters) => {
|
||||
const unreadCount = _getters.getUnreadMessageCount;
|
||||
@@ -50,7 +49,6 @@ export const getters = {
|
||||
return messageType === MESSAGE_TYPE.OUTGOING;
|
||||
});
|
||||
const maxUnreadCount = Math.min(unreadCount, 3);
|
||||
const allUnreadMessages = unreadAgentMessages.splice(-maxUnreadCount);
|
||||
return allUnreadMessages;
|
||||
return unreadAgentMessages.splice(-maxUnreadCount);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ const shouldShowAvatar = (message, nextMessage) => {
|
||||
|
||||
export const groupConversationBySender = conversationsForADate =>
|
||||
conversationsForADate.map((message, index) => {
|
||||
let showAvatar = false;
|
||||
let showAvatar;
|
||||
const isLastMessage = index === conversationsForADate.length - 1;
|
||||
if (isASubmittedFormMessage(message)) {
|
||||
showAvatar = false;
|
||||
|
||||
@@ -88,8 +88,7 @@ export const mutations = {
|
||||
},
|
||||
|
||||
toggleAgentTypingStatus($state, { status }) {
|
||||
const isTyping = status === 'on';
|
||||
$state.uiFlags.isAgentTyping = isTyping;
|
||||
$state.uiFlags.isAgentTyping = status === 'on';
|
||||
},
|
||||
|
||||
setMetaUserLastSeenAt($state, lastSeen) {
|
||||
|
||||
@@ -9,14 +9,14 @@ export const actions = {
|
||||
try {
|
||||
await conversationLabels.create(label);
|
||||
} catch (error) {
|
||||
// Ingore error
|
||||
// Ignore error
|
||||
}
|
||||
},
|
||||
destroy: async (_, label) => {
|
||||
try {
|
||||
await conversationLabels.destroy(label);
|
||||
} catch (error) {
|
||||
// Ingore error
|
||||
// Ignore error
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user