From c4d7b229f435dd440fdceaa7f9e2c574c4cdb090 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 16 Feb 2020 10:14:36 -0600 Subject: [PATCH] We can now ask Google for auth/contacts permission (not readonly!) --- .../contacts/lib/AddContactToolbar.tsx | 12 ++++--- .../contacts/lib/ContactDetail.tsx | 7 ++-- .../contacts/lib/ContactDetailToolbar.tsx | 17 ++++------ .../contacts/lib/ContactList.tsx | 2 +- .../contacts/lib/ContactPerspectivesList.tsx | 16 +++++----- .../contacts/lib/GoogleSupport.ts | 19 ++++++++--- app/internal_packages/contacts/lib/Store.ts | 32 +++++++++++-------- .../contacts/lib/VCFHelpers.ts | 2 +- .../onboarding/lib/onboarding-helpers.ts | 14 +++++--- app/src/flux/models/account.ts | 8 +++++ app/src/flux/stores/account-store.ts | 1 + 11 files changed, 79 insertions(+), 51 deletions(-) diff --git a/app/internal_packages/contacts/lib/AddContactToolbar.tsx b/app/internal_packages/contacts/lib/AddContactToolbar.tsx index 23d3a111b..55727f59b 100644 --- a/app/internal_packages/contacts/lib/AddContactToolbar.tsx +++ b/app/internal_packages/contacts/lib/AddContactToolbar.tsx @@ -17,17 +17,19 @@ class AddContactToolbarWithData extends React.Component } onAdd = () => { - if (showGPeopleReadonlyNotice(this.props.perspective.accountId)) { - return; - } + const { perspective } = this.props; + + if (!('accountId' in perspective)) return; + if (showGPeopleReadonlyNotice(perspective.accountId)) return; + Actions.setFocus({ collection: 'contact', item: null }); Store.setEditing('new'); }; render() { const { editing, perspective } = this.props; - const enabled = editing === false && perspective && perspective.accountId; - const acct = perspective && AccountStore.accountForId(perspective.accountId); + const enabled = 'accountId' in perspective && editing === false && perspective.accountId; + const acct = 'accountId' in perspective && AccountStore.accountForId(perspective.accountId); return (
diff --git a/app/internal_packages/contacts/lib/ContactDetail.tsx b/app/internal_packages/contacts/lib/ContactDetail.tsx index 5a40279a2..1d9f6e795 100644 --- a/app/internal_packages/contacts/lib/ContactDetail.tsx +++ b/app/internal_packages/contacts/lib/ContactDetail.tsx @@ -73,7 +73,7 @@ class ContactDetailWithFocus extends React.Component c.id === focusedId); @@ -95,11 +95,14 @@ class ContactDetailWithFocus extends React.Component { + const { perspective } = this.props; const contact = apply(this.state.contact, this.state.data); + if (!('accountId' in perspective)) return; + const task = contact.id ? SyncbackContactTask.forUpdating({ contact }) - : SyncbackContactTask.forCreating({ contact, accountId: this.props.perspective.accountId }); + : SyncbackContactTask.forCreating({ contact, accountId: perspective.accountId }); Actions.queueTask(task); Store.setEditing(false); }; diff --git a/app/internal_packages/contacts/lib/ContactDetailToolbar.tsx b/app/internal_packages/contacts/lib/ContactDetailToolbar.tsx index 5763006bc..12ec56477 100644 --- a/app/internal_packages/contacts/lib/ContactDetailToolbar.tsx +++ b/app/internal_packages/contacts/lib/ContactDetailToolbar.tsx @@ -50,22 +50,19 @@ class ContactDetailToolbarWithData extends React.Component { - if (showGPeopleReadonlyNotice(this.props.perspective.accountId)) { + const contacts = this.actionSet(); + const contact = contacts[0]; + if (!contact || showGPeopleReadonlyNotice(contact.accountId)) { return; } - const actionSet = this.actionSet(); - Store.setEditing(actionSet[0].id); + Store.setEditing(contact.id); }; _onDelete = () => { const contacts = this.actionSet(); - if ( - contacts.some(c => c.source === 'gpeople') && - showGPeopleReadonlyNotice(this.props.perspective.accountId) - ) { + if (contacts.some(c => c.source === 'gpeople' && showGPeopleReadonlyNotice(c.accountId))) { return; } - Actions.queueTask( DestroyContactTask.forRemoving({ contacts: this.actionSet(), @@ -90,7 +87,7 @@ class ContactDetailToolbarWithData extends React.Component 0) { + if (perspective.type === 'group' && actionSet.length > 0) { commands['core:remove-from-view'] = this._onRemoveFromSource; } if (actionSet.length > 0) { @@ -103,7 +100,7 @@ class ContactDetailToolbarWithData extends React.Component
- {perspective && perspective.type === 'group' && ( + {perspective.type === 'group' && (