Chore: Move conversationStats to a seperate module (#962)

* Chore: Move conversationStats to a seperate module

* Move toggleTyping to conversationTypingStatus

* Remove unused agentTyping flag

* Fix review comments
This commit is contained in:
Pranav Raj S
2020-06-14 14:07:52 +05:30
committed by GitHub
parent 5ec9af9325
commit 5cb88237f5
16 changed files with 139 additions and 98 deletions

View File

@@ -0,0 +1,53 @@
import Vue from 'vue';
import types from '../mutation-types';
import ConversationApi from '../../api/inbox/conversation';
const state = {
mineCount: 0,
unAssignedCount: 0,
allCount: 0,
};
export const getters = {
getStats: $state => $state,
};
export const actions = {
get: async ({ commit }, params) => {
try {
const response = await ConversationApi.meta(params);
const {
data: { meta },
} = response;
commit(types.SET_CONV_TAB_META, meta);
} catch (error) {
// Ignore error
}
},
set({ commit }, meta) {
commit(types.SET_CONV_TAB_META, meta);
},
};
export const mutations = {
[types.SET_CONV_TAB_META](
$state,
{
mine_count: mineCount,
unassigned_count: unAssignedCount,
all_count: allCount,
} = {}
) {
Vue.set($state, 'mineCount', mineCount);
Vue.set($state, 'allCount', allCount);
Vue.set($state, 'unAssignedCount', unAssignedCount);
},
};
export default {
namespaced: true,
state,
getters,
actions,
mutations,
};