From a748ae3cf12fb16fd73c512cbbf1a53e54002045 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Dec 2020 10:01:06 +0200 Subject: [PATCH] Tasks: remove the categories property when there are no tags. Fixes #179 --- src/pim-types.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pim-types.ts b/src/pim-types.ts index 25b1c25..e201f8c 100644 --- a/src/pim-types.ts +++ b/src/pim-types.ts @@ -210,9 +210,14 @@ export class TaskType extends EventType { set tags(tags: string[]) { const property = this.component.getFirstProperty("categories"); + const empty = tags.length === 0; if (property) { - property.setValues(tags); - } else { + if (empty) { + this.component.removeAllProperties("categories"); + } else { + property.setValues(tags); + } + } else if (!empty) { const newProp = new ICAL.Property("categories", this.component); newProp.setValues(tags); this.component.addProperty(newProp);