fix: Remove duplicate API calls for conversation (#1419)

This commit is contained in:
Pranav Raj S 2020-11-17 09:15:57 +05:30 committed by GitHub
parent 9d2542eecd
commit 2d70131097
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -184,7 +184,9 @@ export default {
this.fetchConversations();
},
fetchConversations() {
this.$store.dispatch('fetchAllConversations', this.conversationFilters);
this.$store
.dispatch('fetchAllConversations', this.conversationFilters)
.then(() => this.$emit('conversation-load'));
},
updateAssigneeTab(selectedTab) {
if (this.activeAssigneeTab !== selectedTab) {

View file

@ -1,6 +1,10 @@
<template>
<section class="app-content columns">
<chat-list :conversation-inbox="inboxId" :label="label">
<chat-list
:conversation-inbox="inboxId"
:label="label"
@conversation-load="onConversationLoad"
>
<button class="search--button" @click="onSearch">
<i class="ion-ios-search-strong search--icon" />
<div class="text-truncate">
@ -83,24 +87,23 @@ export default {
mounted() {
this.$store.dispatch('agents/get');
this.initialize();
this.fetchConversation();
this.$watch('$store.state.route', () => this.initialize());
this.$watch('chatList.length', () => {
this.fetchConversation();
this.setActiveChat();
});
},
methods: {
onConversationLoad() {
this.fetchConversationIfUnavailable();
},
initialize() {
this.$store.dispatch('setActiveInbox', this.inboxId);
this.setActiveChat();
},
fetchConversation() {
fetchConversationIfUnavailable() {
if (!this.conversationId) {
return;
}