diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-03-04 09:55:40 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-03-04 10:53:36 +0100 |
commit | a207d5e2be8091ca9c93b450fdaa07c6ad5a78eb (patch) | |
tree | a9ee8d476dfc44fe9b86f0ee8aa124e121b22671 /src/models | |
parent | bdd93836aa0613e5f9c61f2496505e4c45f1febc (diff) |
Add REV on update
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/contact.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/models/contact.js b/src/models/contact.js index d284e7fc..82b418e5 100644 --- a/src/models/contact.js +++ b/src/models/contact.js @@ -67,6 +67,13 @@ export default class Contact { console.info('This contact did not have a proper uid. Setting a new one for ', this) this.vCard.addPropertyWithValue('uid', uuid()) } + + // if no rev set, init one + if (!this.vCard.hasProperty('rev')) { + const rev = new ICAL.VCardTime() + rev.fromUnixTime(Date.now() / 1000) + this.rev = rev + } } /** @@ -138,6 +145,27 @@ export default class Contact { } /** + * Return the rev + * + * @readonly + * @memberof Contact + */ + get rev() { + return this.vCard.getFirstPropertyValue('rev') + } + + /** + * Set the rev + * + * @param {string} rev the rev to set + * @memberof Contact + */ + set rev(rev) { + this.vCard.updatePropertyWithValue('rev', rev) + return true + } + + /** * Return the key * * @readonly |