diff --git a/app/services/conversations/filter_service.rb b/app/services/conversations/filter_service.rb index d91916b12..012dd662f 100644 --- a/app/services/conversations/filter_service.rb +++ b/app/services/conversations/filter_service.rb @@ -58,8 +58,9 @@ class Conversations::FilterService < FilterService def conversations @conversations = @conversations.includes( - :taggings, :inbox, { assignee: { avatar_attachment: [:blob] } }, { contact: { avatar_attachment: [:blob] } }, :team + :taggings, :inbox, { assignee: { avatar_attachment: [:blob] } }, { contact: { avatar_attachment: [:blob] } }, :team, :messages, :contact_inbox ) + @conversations.latest.page(current_page) end end diff --git a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder index 9ea7df4e6..63e1f22fb 100644 --- a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder +++ b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder @@ -17,7 +17,7 @@ json.meta do end json.id conversation.display_id -if conversation.messages.count.zero? +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)]