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(); this.fetchConversations();
}, },
fetchConversations() { fetchConversations() {
this.$store.dispatch('fetchAllConversations', this.conversationFilters); this.$store
.dispatch('fetchAllConversations', this.conversationFilters)
.then(() => this.$emit('conversation-load'));
}, },
updateAssigneeTab(selectedTab) { updateAssigneeTab(selectedTab) {
if (this.activeAssigneeTab !== selectedTab) { if (this.activeAssigneeTab !== selectedTab) {

View file

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