From 3f468aaba08d888e27d2d819979ca7eec8343e01 Mon Sep 17 00:00:00 2001 From: whoalin1 Date: Wed, 7 Oct 2026 01:19:54 +0300 Subject: [PATCH] fix(contacts): create new contacts in the selected address book Assisted-by: Cursor:grok-4.7 Signed-off-by: whoalin1 --- src/components/ContactDetails.vue | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/components/ContactDetails.vue b/src/components/ContactDetails.vue index 785da90b6..35b22473c 100644 --- a/src/components/ContactDetails.vue +++ b/src/components/ContactDetails.vue @@ -1264,10 +1264,31 @@ export default defineComponent({ groupNames: this.newGroupsValue, contact: this.contact, }) + + // New contact + different address book: move locally before createVCard + // so Activity credits the final book (create-then-move logged the default). + // See https://github.com/nextcloud/contacts/issues/5757 + const pendingAddressBookId = this.newAddressBook + const isNewContact = !this.contact.dav + if ( + isNewContact + && pendingAddressBookId + && pendingAddressBookId !== this.contact.addressbook.id + ) { + const addressbook = this.addressbooks.find((ab) => ab.id === pendingAddressBookId) + if (addressbook) { + this.updateAddressBookAccesses(pendingAddressBookId) + // createVCard uses localContact.addressbook — keep the clone in sync + this.localContact.addressbook = addressbook + await this.moveContactToAddressbook(pendingAddressBookId) + this.newAddressBook = null + } + } + await this.updateContact() if (this.newAddressBook && this.newAddressBook !== this.contact.addressbook.id) { this.updateAddressBookAccesses(this.newAddressBook) - this.moveContactToAddressbook(this.newAddressBook) + await this.moveContactToAddressbook(this.newAddressBook) this.newAddressBook = null } this.editMode = false