From e6750d468d9c18905b67fc9950f93861964575ec Mon Sep 17 00:00:00 2001 From: daniel gannage Date: Mon, 3 Oct 2022 16:50:46 -0400 Subject: [PATCH] Update conversation on attributes changed --- app/javascript/dashboard/helper/actionCable.js | 6 ++++++ app/listeners/action_cable_listener.rb | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/app/javascript/dashboard/helper/actionCable.js b/app/javascript/dashboard/helper/actionCable.js index e00cf283f..ba21a3e6a 100644 --- a/app/javascript/dashboard/helper/actionCable.js +++ b/app/javascript/dashboard/helper/actionCable.js @@ -25,6 +25,7 @@ class ActionCableConnector extends BaseActionCableConnector { 'notification.created': this.onNotificationCreated, 'first.reply.created': this.onFirstReplyCreated, 'conversation.read': this.onConversationRead, + 'conversation.updated': this.onConversationUpdated, }; } @@ -85,6 +86,11 @@ class ActionCableConnector extends BaseActionCableConnector { this.fetchConversationStats(); }; + onConversationUpdated = data => { + this.app.$store.dispatch('updateConversation', data); + this.fetchConversationStats(); + }; + onTypingOn = ({ conversation, user }) => { const conversationId = conversation.id; diff --git a/app/listeners/action_cable_listener.rb b/app/listeners/action_cable_listener.rb index 3d3bbdf83..e7c025600 100644 --- a/app/listeners/action_cable_listener.rb +++ b/app/listeners/action_cable_listener.rb @@ -52,6 +52,13 @@ class ActionCableListener < BaseListener broadcast(account, tokens, CONVERSATION_STATUS_CHANGED, conversation.push_event_data) end + def conversation_updated(event) + conversation, account = extract_conversation_and_account(event) + tokens = user_tokens(account, conversation.inbox.members) + contact_inbox_tokens(conversation.contact_inbox) + + broadcast(account, tokens, CONVERSATION_UPDATED, conversation.push_event_data) + end + def conversation_typing_on(event) conversation = event.data[:conversation] account = conversation.account