Chore: Remove selectedChat from store (#1087)

* Chore: Remove selected chat from store
This commit is contained in:
Pranav Raj S
2020-07-23 23:33:17 +05:30
committed by GitHub
parent e72f29a26e
commit c7d962b20f
7 changed files with 76 additions and 84 deletions

View File

@@ -84,35 +84,21 @@ const actions = {
}
},
setActiveChat(store, data) {
const { commit } = store;
const localDispatch = store.dispatch;
let donePromise = null;
commit(types.default.CURRENT_CHAT_WINDOW, data);
async setActiveChat({ commit, dispatch }, data) {
commit(types.default.SET_CURRENT_CHAT_WINDOW, data);
commit(types.default.CLEAR_ALL_MESSAGES_LOADED);
if (data.dataFetched === undefined) {
donePromise = new Promise(resolve => {
localDispatch('fetchPreviousMessages', {
try {
await dispatch('fetchPreviousMessages', {
conversationId: data.id,
before: data.messages[0].id,
})
.then(() => {
Vue.set(data, 'dataFetched', true);
resolve();
})
.catch(() => {
// Handle error
});
});
} else {
donePromise = new Promise(resolve => {
commit(types.default.SET_CHAT_META, { id: data.id });
resolve();
});
});
Vue.set(data, 'dataFetched', true);
} catch (error) {
// Ignore error
}
}
return donePromise;
},
assignAgent: async ({ commit }, { conversationId, agentId }) => {