diff options
author | Raimund Schlüßler <raimund.schluessler@mailbox.org> | 2018-12-29 23:40:46 +0300 |
---|---|---|
committer | Raimund Schlüßler <raimund.schluessler@mailbox.org> | 2019-01-25 22:38:10 +0300 |
commit | 78304c5e87f26dbcdb941785ac24a9194ec08d46 (patch) | |
tree | bdfbab242015b0218cec31eaa8556199d42c0e99 /src/models | |
parent | c6f3ab38e4f46b380051d9f799048e6b1ce89d37 (diff) |
Don't require raw vcalendar to construct a Task
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/task.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/models/task.js b/src/models/task.js index 8c7f003c..bea5a8f2 100644 --- a/src/models/task.js +++ b/src/models/task.js @@ -32,10 +32,9 @@ export default class Task { * * @param {string} vcalendar the vcalendar data as string with proper new lines * @param {object} calendar the calendar which the task belongs to - * @param {object} raw the raw vcalendar data * @memberof Task */ - constructor(vcalendar, calendar, raw) { + constructor(vcalendar, calendar) { if (typeof vcalendar !== 'string' || vcalendar.length === 0) { throw new Error('Invalid vCalendar') } @@ -62,8 +61,6 @@ export default class Task { console.debug('This task did not have a proper uid. Setting a new one for ', this) this.vtodo.addPropertyWithValue('uid', uuid()) } - - this.uri = raw.url.substr(raw.url.lastIndexOf('/') + 1) } /** @@ -124,6 +121,19 @@ export default class Task { } /** + * Return the uri + * + * @readonly + * @memberof Task + */ + get uri() { + if (this.dav) { + return this.dav.url.substr(this.dav.url.lastIndexOf('/') + 1) + } + return '' + } + + /** * Return the uid * * @readonly |