Update conversation on attributes changed

This commit is contained in:
daniel gannage 2022-10-03 16:50:46 -04:00
parent 00a621ee22
commit e6750d468d
2 changed files with 13 additions and 0 deletions

View file

@ -25,6 +25,7 @@ class ActionCableConnector extends BaseActionCableConnector {
'notification.created': this.onNotificationCreated, 'notification.created': this.onNotificationCreated,
'first.reply.created': this.onFirstReplyCreated, 'first.reply.created': this.onFirstReplyCreated,
'conversation.read': this.onConversationRead, 'conversation.read': this.onConversationRead,
'conversation.updated': this.onConversationUpdated,
}; };
} }
@ -85,6 +86,11 @@ class ActionCableConnector extends BaseActionCableConnector {
this.fetchConversationStats(); this.fetchConversationStats();
}; };
onConversationUpdated = data => {
this.app.$store.dispatch('updateConversation', data);
this.fetchConversationStats();
};
onTypingOn = ({ conversation, user }) => { onTypingOn = ({ conversation, user }) => {
const conversationId = conversation.id; const conversationId = conversation.id;

View file

@ -52,6 +52,13 @@ class ActionCableListener < BaseListener
broadcast(account, tokens, CONVERSATION_STATUS_CHANGED, conversation.push_event_data) broadcast(account, tokens, CONVERSATION_STATUS_CHANGED, conversation.push_event_data)
end 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) def conversation_typing_on(event)
conversation = event.data[:conversation] conversation = event.data[:conversation]
account = conversation.account account = conversation.account