fix: Update unread_count being 0 if agent has not seen the conversation (#7690)
This commit is contained in:
@@ -166,11 +166,11 @@ class Conversation < ApplicationRecord
|
||||
end
|
||||
|
||||
def unread_messages
|
||||
messages.created_since(agent_last_seen_at)
|
||||
agent_last_seen_at.present? ? messages.created_since(agent_last_seen_at) : messages
|
||||
end
|
||||
|
||||
def unread_incoming_messages
|
||||
messages.incoming.created_since(agent_last_seen_at)
|
||||
unread_messages.incoming
|
||||
end
|
||||
|
||||
def push_event_data
|
||||
|
||||
@@ -497,6 +497,12 @@ RSpec.describe Conversation do
|
||||
it 'returns unread incoming messages' do
|
||||
expect(unread_incoming_messages).to contain_exactly(message)
|
||||
end
|
||||
|
||||
it 'returns unread incoming messages even if the agent has not seen the conversation' do
|
||||
conversation.update!(agent_last_seen_at: nil)
|
||||
|
||||
expect(unread_incoming_messages).to contain_exactly(message)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#push_event_data' do
|
||||
|
||||
Reference in New Issue
Block a user