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
|
end
|
||||||
|
|
||||||
def unread_messages
|
def unread_messages
|
||||||
messages.created_since(agent_last_seen_at)
|
agent_last_seen_at.present? ? messages.created_since(agent_last_seen_at) : messages
|
||||||
end
|
end
|
||||||
|
|
||||||
def unread_incoming_messages
|
def unread_incoming_messages
|
||||||
messages.incoming.created_since(agent_last_seen_at)
|
unread_messages.incoming
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_event_data
|
def push_event_data
|
||||||
|
|||||||
@@ -497,6 +497,12 @@ RSpec.describe Conversation do
|
|||||||
it 'returns unread incoming messages' do
|
it 'returns unread incoming messages' do
|
||||||
expect(unread_incoming_messages).to contain_exactly(message)
|
expect(unread_incoming_messages).to contain_exactly(message)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe '#push_event_data' do
|
describe '#push_event_data' do
|
||||||
|
|||||||
Reference in New Issue
Block a user