fix: Update unread_messages count in WhatsApp inboxes (#6154)
* fix: Update unread_count from backend instead of computing on the frontend * Fix spec * Remove status indicator on private notifications * CodeClimate fix * CodeClimate
This commit is contained in:
@@ -186,7 +186,7 @@ export default {
|
|||||||
return `https://www.instagram.com/stories/${storySender}/${storyId}`;
|
return `https://www.instagram.com/stories/${storySender}/${storyId}`;
|
||||||
},
|
},
|
||||||
showStatusIndicators() {
|
showStatusIndicators() {
|
||||||
if ((this.isOutgoing || this.isTemplate) && !this.private) {
|
if ((this.isOutgoing || this.isTemplate) && !this.isPrivate) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ export const mutations = {
|
|||||||
} else {
|
} else {
|
||||||
chat.messages.push(message);
|
chat.messages.push(message);
|
||||||
chat.timestamp = message.created_at;
|
chat.timestamp = message.created_at;
|
||||||
|
const { conversation: { unread_count: unreadCount = 0 } = {} } = message;
|
||||||
|
chat.unread_count = unreadCount;
|
||||||
if (selectedChatId === conversationId) {
|
if (selectedChatId === conversationId) {
|
||||||
window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE);
|
window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ describe('#mutations', () => {
|
|||||||
created_at: 1602256198,
|
created_at: 1602256198,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
unread_count: 0,
|
||||||
timestamp: 1602256198,
|
timestamp: 1602256198,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -130,6 +131,7 @@ describe('#mutations', () => {
|
|||||||
created_at: 1602256198,
|
created_at: 1602256198,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
unread_count: 0,
|
||||||
timestamp: 1602256198,
|
timestamp: 1602256198,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -104,7 +104,10 @@ class Message < ApplicationRecord
|
|||||||
created_at: created_at.to_i,
|
created_at: created_at.to_i,
|
||||||
message_type: message_type_before_type_cast,
|
message_type: message_type_before_type_cast,
|
||||||
conversation_id: conversation.display_id,
|
conversation_id: conversation.display_id,
|
||||||
conversation: { assignee_id: conversation.assignee_id }
|
conversation: {
|
||||||
|
assignee_id: conversation.assignee_id,
|
||||||
|
unread_count: conversation.unread_incoming_messages.count
|
||||||
|
}
|
||||||
)
|
)
|
||||||
data.merge!(echo_id: echo_id) if echo_id.present?
|
data.merge!(echo_id: echo_id) if echo_id.present?
|
||||||
validate_instagram_story if instagram_story_mention?
|
validate_instagram_story if instagram_story_mention?
|
||||||
|
|||||||
Reference in New Issue
Block a user