From b0387da59c09841f417cd53c367824e891a6797f Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 16 Feb 2020 10:14:47 -0600 Subject: [PATCH] Fix support for changing names of google contacts when displayName is provided --- app/internal_packages/contacts/lib/ContactInfoMapping.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/internal_packages/contacts/lib/ContactInfoMapping.ts b/app/internal_packages/contacts/lib/ContactInfoMapping.ts index 65709774b..56111fa5f 100644 --- a/app/internal_packages/contacts/lib/ContactInfoMapping.ts +++ b/app/internal_packages/contacts/lib/ContactInfoMapping.ts @@ -216,6 +216,11 @@ export function applyToGoogle(contact: Contact, changes: Partial) { const val = changes[key]; if (key === 'name') { + if ('displayName' in val) { + // UI only edits surname + given name so we sync the full string + // to the new values here if Google provided us with one initially. + val.displayName = VCFHelpers.formatDisplayName(val); + } if (!info.names || info.names.length === 0) { info.names = [Object.assign({ metadata }, val)]; } else { @@ -248,7 +253,7 @@ export function applyToGoogle(contact: Contact, changes: Partial) { export function parse(contact: Contact): ContactParseResult { try { - return !contact.info + return !contact.info || Object.keys(contact.info).length === 0 ? fromContact(contact) : 'vcf' in contact.info ? fromVCF(contact.info)