Chore: Fix issues with conversation data models (#1000)

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-07-04 19:46:17 +05:30
committed by GitHub
parent 36661ea45d
commit 4612494923
15 changed files with 147 additions and 51 deletions

View File

@@ -156,19 +156,24 @@ const actions = {
commit(types.default.ADD_MESSAGE, message);
},
addConversation({ commit, state }, conversation) {
addConversation({ commit, state, dispatch }, conversation) {
const { currentInbox } = state;
if (!currentInbox || Number(currentInbox) === conversation.inbox_id) {
const {
inbox_id: inboxId,
meta: { sender },
} = conversation;
if (!currentInbox || Number(currentInbox) === inboxId) {
commit(types.default.ADD_CONVERSATION, conversation);
commit(
`contacts/${types.default.SET_CONTACT_ITEM}`,
conversation.meta.sender
);
dispatch('contacts/setContact', sender);
}
},
updateConversation({ commit }, conversation) {
updateConversation({ commit, dispatch }, conversation) {
const {
meta: { sender },
} = conversation;
commit(types.default.UPDATE_CONVERSATION, conversation);
dispatch('contacts/setContact', sender);
},
markMessagesRead: async ({ commit }, data) => {