From c39588e228a666be8d2ac9dfcc987261ad12b887 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 24 Jan 2024 23:21:53 +0530 Subject: [PATCH] fix: save copy of all contacts --- frontend/src/components/Controls/MultiselectInput.vue | 5 +++-- frontend/src/stores/contacts.js | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Controls/MultiselectInput.vue b/frontend/src/components/Controls/MultiselectInput.vue index c7704032..b61982a9 100644 --- a/frontend/src/components/Controls/MultiselectInput.vue +++ b/frontend/src/components/Controls/MultiselectInput.vue @@ -110,7 +110,7 @@ const props = defineProps({ const values = defineModel() -const { contacts } = contactsStore() +const { getContacts } = contactsStore() const emails = ref([]) const search = ref(null) @@ -119,8 +119,9 @@ const query = ref('') const showOptions = ref(false) const emailList = computed(() => { + let contacts = getContacts() || [] return ( - contacts.data + contacts ?.filter((contact) => contact.email_id) .map((contact) => { return { diff --git a/frontend/src/stores/contacts.js b/frontend/src/stores/contacts.js index 735f9948..04b17ffc 100644 --- a/frontend/src/stores/contacts.js +++ b/frontend/src/stores/contacts.js @@ -6,6 +6,7 @@ export const contactsStore = defineStore('crm-contacts', () => { let contactsByPhone = reactive({}) let contactsByName = reactive({}) let leadContactsByPhone = reactive({}) + let allContacts = reactive([]) const contacts = createResource({ url: 'crm.api.session.get_contacts', @@ -20,6 +21,7 @@ export const contactsStore = defineStore('crm-contacts', () => { contactsByPhone[contact.mobile_no] = contact contactsByName[contact.name] = contact } + allContacts = [...contacts] return contacts }, onError(error) { @@ -63,8 +65,13 @@ export const contactsStore = defineStore('crm-contacts', () => { return leadContactsByPhone[mobile_no] } + function getContacts() { + return allContacts || contacts?.data || [] + } + return { contacts, + getContacts, getContact, getContactByName, getLeadContact,