From a207d5e2be8091ca9c93b450fdaa07c6ad5a78eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 4 Mar 2019 09:55:40 +0100 Subject: Add REV on update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- src/models/contact.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/models') 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 + } } /** @@ -137,6 +144,27 @@ export default class Contact { return true } + /** + * 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 * -- cgit v1.2.3