fix: Limit count query to return only 10 values (#7704)
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
/>
|
/>
|
||||||
<li v-show="unreadMessageCount != 0" class="unread--toast">
|
<li v-show="unreadMessageCount != 0" class="unread--toast">
|
||||||
<span>
|
<span>
|
||||||
{{ unreadMessageCount }}
|
{{ unreadMessageCount > 9 ? '9+' : unreadMessageCount }}
|
||||||
{{
|
{{
|
||||||
unreadMessageCount > 1
|
unreadMessageCount > 1
|
||||||
? $t('CONVERSATION.UNREAD_MESSAGES')
|
? $t('CONVERSATION.UNREAD_MESSAGES')
|
||||||
@@ -314,7 +314,7 @@ export default {
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
unreadMessageCount() {
|
unreadMessageCount() {
|
||||||
return this.currentChat.unread_count;
|
return this.currentChat.unread_count || 0;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class Conversation < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unread_incoming_messages
|
def unread_incoming_messages
|
||||||
unread_messages.incoming
|
unread_messages.incoming.last(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_event_data
|
def push_event_data
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ end
|
|||||||
json.id conversation.display_id
|
json.id conversation.display_id
|
||||||
if conversation.messages.first.blank?
|
if conversation.messages.first.blank?
|
||||||
json.messages []
|
json.messages []
|
||||||
elsif conversation.unread_incoming_messages.count.zero?
|
|
||||||
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
|
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
json.account_id conversation.account_id
|
json.account_id conversation.account_id
|
||||||
|
|||||||
Reference in New Issue
Block a user