Fix support for changing names of google contacts when displayName is provided

This commit is contained in:
Ben Gotow 2020-02-16 10:14:47 -06:00
parent c4d7b229f4
commit b0387da59c

View file

@ -216,6 +216,11 @@ export function applyToGoogle(contact: Contact, changes: Partial<ContactBase>) {
const val = changes[key]; const val = changes[key];
if (key === 'name') { 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) { if (!info.names || info.names.length === 0) {
info.names = [Object.assign({ metadata }, val)]; info.names = [Object.assign({ metadata }, val)];
} else { } else {
@ -248,7 +253,7 @@ export function applyToGoogle(contact: Contact, changes: Partial<ContactBase>) {
export function parse(contact: Contact): ContactParseResult { export function parse(contact: Contact): ContactParseResult {
try { try {
return !contact.info return !contact.info || Object.keys(contact.info).length === 0
? fromContact(contact) ? fromContact(contact)
: 'vcf' in contact.info : 'vcf' in contact.info
? fromVCF(contact.info) ? fromVCF(contact.info)