fix: last_activity_at is nil when conv is created (#9934)

The payload does not include last_activity_at when the conversation is created. Because of this the frontend is not able to sort the conversations when appending this. Another problem is that the last_activity_at is not always present, it is added only when a message is created, and it updates it. So this can be nil when the conversation is created, so we fallback to created_at only at the presentation layer
This commit is contained in:
Shivam Mishra
2024-08-12 15:08:06 +05:30
committed by GitHub
parent 8ea412bc85
commit 6196a6d99a
3 changed files with 41 additions and 0 deletions

View File

@@ -124,6 +124,10 @@ class Conversation < ApplicationRecord
last_message_in_messaging_window?(messaging_window)
end
def last_activity_at
self[:last_activity_at] || created_at
end
def last_incoming_message
messages&.incoming&.last
end