diff --git a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue
index 9ab5fd9df..6b5a2cb8c 100644
--- a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue
+++ b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue
@@ -45,7 +45,7 @@
/>
- {{ unreadMessageCount }}
+ {{ unreadMessageCount > 9 ? '9+' : unreadMessageCount }}
{{
unreadMessageCount > 1
? $t('CONVERSATION.UNREAD_MESSAGES')
@@ -314,7 +314,7 @@ export default {
return '';
},
unreadMessageCount() {
- return this.currentChat.unread_count;
+ return this.currentChat.unread_count || 0;
},
},
diff --git a/app/models/conversation.rb b/app/models/conversation.rb
index 80b930493..223b1720d 100644
--- a/app/models/conversation.rb
+++ b/app/models/conversation.rb
@@ -170,7 +170,7 @@ class Conversation < ApplicationRecord
end
def unread_incoming_messages
- unread_messages.incoming
+ unread_messages.incoming.last(10)
end
def push_event_data
diff --git a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder
index 3cd41efb9..4031bd1b9 100644
--- a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder
+++ b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder
@@ -19,10 +19,8 @@ end
json.id conversation.display_id
if conversation.messages.first.blank?
json.messages []
-elsif conversation.unread_incoming_messages.count.zero?
- json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
else
- json.messages conversation.unread_messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
+ json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
end
json.account_id conversation.account_id