feat: Ability to lock to single conversation (#5881)

Adds the ability to lock conversation to a single thread for Whatsapp and Sms Inboxes when using outbound messages.

demo: https://www.loom.com/share/c9e1e563c8914837a4139dfdd2503fef

fixes: #4975

Co-authored-by: Nithin David <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
Sojan Jose
2022-11-25 13:01:04 +03:00
committed by GitHub
parent 8813c77907
commit b05d06a28a
13 changed files with 171 additions and 47 deletions

View File

@@ -89,7 +89,19 @@ export const mutations = {
},
[types.default.ADD_CONTACT_CONVERSATION]: ($state, { id, data }) => {
const conversations = $state.records[id] || [];
Vue.set($state.records, id, [...conversations, data]);
const updatedConversations = [...conversations];
const index = conversations.findIndex(
conversation => conversation.id === data.id
);
if (index !== -1) {
updatedConversations[index] = { ...conversations[index], ...data };
} else {
updatedConversations.push(data);
}
Vue.set($state.records, id, updatedConversations);
},
[types.default.DELETE_CONTACT_CONVERSATION]: ($state, id) => {
Vue.delete($state.records, id);