Skip to content

Commit

Permalink
Merge pull request #2437 from nextcloud/fix/noid/empty-categories
Browse files Browse the repository at this point in the history
fix: don't show empty category for empty CATEGORIES param
  • Loading branch information
raimund-schluessler authored Jan 3, 2024
2 parents dfec366 + cff21ca commit 5c6bcc7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export default class Task {
let tags = []
for (const t of this.vtodo.getAllProperties('categories')) {
if (t) {
tags = tags.concat(t.getValues())
tags = tags.concat(t.getValues().filter(t => t))
}
}
return tags
Expand Down
12 changes: 12 additions & 0 deletions tests/assets/loadAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ LAST-MODIFIED:20190918T095816
UID:pwen9kz29f
SUMMARY:Test 1
END:VTODO
END:VCALENDAR`,
'vcalendars/vcalendar-categories-empty': `BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Nextcloud Tasks 0.11.3
BEGIN:VTODO
CREATED:20181119T183919
DTSTAMP:20190918T095816
LAST-MODIFIED:20190918T095816
UID:pwen9kz29f
SUMMARY:Test 1
CATEGORIES:
END:VTODO
END:VCALENDAR`,
'vcalendars/calendar1/vcalendar-vtodo1': `BEGIN:VCALENDAR
VERSION:2.0
Expand Down
5 changes: 5 additions & 0 deletions tests/javascript/unit/models/task.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ describe('task', () => {
expect(task.tags.length).toEqual(0)
})

it('Should show no tag if CATEGORIES parameter is empty.', () => {
const task = new Task(loadICS('vcalendars/vcalendar-categories-empty'), {})
expect(task.tags.length).toEqual(0)
})

it('Should remove status property when set to null', () => {
const task = new Task(loadICS('vcalendars/vcalendar-default'), {})
task.status = null
Expand Down

0 comments on commit 5c6bcc7

Please sign in to comment.