fix: hydrate realtime conversations before rendering
Build and publish Docker images / Build and publish images (push) Successful in 3m16s
Build and publish Docker images / Build and publish images (push) Successful in 3m16s
This commit is contained in:
@@ -24,6 +24,8 @@ class ActionCableConnector extends BaseActionCableConnector {
|
||||
'user:logout': this.onLogout,
|
||||
'page:reload': this.onReload,
|
||||
'assignee.changed': this.onAssigneeChanged,
|
||||
'conversation.assigned': this.onConversationAssigned,
|
||||
'conversation.unassigned': this.onConversationAssigned,
|
||||
'conversation.typing_on': this.onTypingOn,
|
||||
'conversation.typing_off': this.onTypingOff,
|
||||
'conversation.contact_changed': this.onConversationContactChange,
|
||||
@@ -88,8 +90,18 @@ class ActionCableConnector extends BaseActionCableConnector {
|
||||
this.fetchConversationStats();
|
||||
};
|
||||
|
||||
onConversationCreated = data => {
|
||||
this.app.$store.dispatch('addConversation', data);
|
||||
onConversationAssigned = data => {
|
||||
if (data?.id) {
|
||||
this.app.$store.dispatch('getConversation', data.id);
|
||||
}
|
||||
this.fetchConversationStats();
|
||||
};
|
||||
|
||||
onConversationCreated = async data => {
|
||||
const added = await this.app.$store.dispatch('addConversation', data);
|
||||
if (added && !data.messages?.length) {
|
||||
await this.app.$store.dispatch('getConversation', data.id);
|
||||
}
|
||||
this.fetchConversationStats();
|
||||
};
|
||||
|
||||
@@ -105,8 +117,24 @@ class ActionCableConnector extends BaseActionCableConnector {
|
||||
conversation: { last_activity_at: lastActivityAt },
|
||||
conversation_id: conversationId,
|
||||
} = data;
|
||||
const hasConversation =
|
||||
this.app.$store.state?.conversations?.allConversations?.some(
|
||||
conversation => Number(conversation.id) === Number(conversationId)
|
||||
);
|
||||
const applied = await this.app.$store.dispatch('addMessage', data);
|
||||
if (!applied) return;
|
||||
if (!applied) {
|
||||
if (!hasConversation) {
|
||||
const conversation = await this.app.$store.dispatch(
|
||||
'getConversation',
|
||||
conversationId
|
||||
);
|
||||
if (conversation) {
|
||||
DashboardAudioNotificationHelper.onNewMessage(data);
|
||||
this.fetchConversationStats();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DashboardAudioNotificationHelper.onNewMessage(data);
|
||||
this.app.$store.dispatch('updateConversationLastActivity', {
|
||||
|
||||
Reference in New Issue
Block a user