carnet panel contact
This commit is contained in:
parent
6beb394a84
commit
a10660a27f
@ -454,13 +454,16 @@ export default function CarnetPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { content } = await response.json();
|
const { content } = await response.json();
|
||||||
const contacts = parseVCardContent(content);
|
|
||||||
|
|
||||||
// Remove the contact
|
// Split the content into individual vCards and filter out the one to delete
|
||||||
const updatedContacts = contacts.filter(c => c.id !== contact.id);
|
const vcards = content.split('BEGIN:VCARD').filter(section => section.trim());
|
||||||
|
const updatedVcards = vcards.filter(section => {
|
||||||
|
const vcard = parseVCard('BEGIN:VCARD' + section);
|
||||||
|
return vcard.uid?.[0]?.value !== contact.id;
|
||||||
|
});
|
||||||
|
|
||||||
// Generate new VCF content
|
// Join the remaining vCards back together
|
||||||
const vcfContent = updatedContacts.map(c => generateVCardContent(c)).join('\n');
|
const vcfContent = updatedVcards.map(section => 'BEGIN:VCARD' + section).join('\n');
|
||||||
|
|
||||||
// Save the updated VCF file
|
// Save the updated VCF file
|
||||||
const saveResponse = await fetch('/api/nextcloud/files', {
|
const saveResponse = await fetch('/api/nextcloud/files', {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user