From de6ab10714a71a6d4ec502a0f56c3ac262f2c0b8 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 8 Aug 2024 15:26:59 +0530 Subject: [PATCH] fix: last_activity_at is nil when conv is created The payload does not include last_activity_at when the conversation is created. Becuase 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 --- app/presenters/conversations/event_data_presenter.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/presenters/conversations/event_data_presenter.rb b/app/presenters/conversations/event_data_presenter.rb index 67c7dc1dd..6e161a89e 100644 --- a/app/presenters/conversations/event_data_presenter.rb +++ b/app/presenters/conversations/event_data_presenter.rb @@ -40,6 +40,7 @@ class Conversations::EventDataPresenter < SimpleDelegator { agent_last_seen_at: agent_last_seen_at.to_i, contact_last_seen_at: contact_last_seen_at.to_i, + last_activity_at: last_activity_at ? last_activity_at.to_i : created_at.to_i, timestamp: last_activity_at.to_i, created_at: created_at.to_i }