diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-04-02 13:28:53 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-04-02 13:28:53 +0200 |
commit | 1466de563cfb93d5c5db43d59f0e36aee9e3a42f (patch) | |
tree | 903592ff78285566add56a00f658c53689fff376 /src/models | |
parent | 08fab90457f499f07ee7a632eca048763b7d8c63 (diff) |
Remove some properties if empty
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/contact.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/models/contact.js b/src/models/contact.js index 14ea06ff..c4eebecc 100644 --- a/src/models/contact.js +++ b/src/models/contact.js @@ -259,6 +259,12 @@ export default class Contact { * @memberof Contact */ set groups(groups) { + // delete the title if empty + if (isEmpty(groups)) { + this.vCard.removeProperty('categories') + return true + } + if (Array.isArray(groups)) { let property = this.vCard.getFirstProperty('categories') if (!property) { @@ -308,6 +314,10 @@ export default class Contact { * @memberof Contact */ set org(org) { + // delete the org if empty + if (isEmpty(org)) { + return this.vCard.removeProperty('org') + } return this.vCard.updatePropertyWithValue('org', org) } @@ -328,6 +338,10 @@ export default class Contact { * @memberof Contact */ set title(title) { + // delete the title if empty + if (isEmpty(title)) { + return this.vCard.removeProperty('title') + } return this.vCard.updatePropertyWithValue('title', title) } |