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