Chore: Fix issues with conversation data models (#1000)
Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -140,9 +140,10 @@ const mutations = {
|
||||
c => c.id === conversation.id
|
||||
);
|
||||
if (currentConversationIndex > -1) {
|
||||
const { messages, ...conversationAttributes } = conversation;
|
||||
const currentConversation = {
|
||||
...allConversations[currentConversationIndex],
|
||||
...conversation,
|
||||
...conversationAttributes,
|
||||
};
|
||||
Vue.set(allConversations, currentConversationIndex, currentConversation);
|
||||
if (_state.selectedChat.id === conversation.id) {
|
||||
|
||||
Reference in New Issue
Block a user