From c8c6f1f8a1691928b3128d520b229f6ab4fff1f3 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sat, 14 Oct 2023 14:35:47 -0700 Subject: [PATCH] tags: remove some filters Signed-off-by: Varun Patil --- lib/Controller/TagsController.php | 4 ++++ src/components/modal/EditTags.vue | 10 ++-------- src/services/dav/tags.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/Controller/TagsController.php b/lib/Controller/TagsController.php index e1d34976..611864d3 100644 --- a/lib/Controller/TagsController.php +++ b/lib/Controller/TagsController.php @@ -33,6 +33,10 @@ class TagsController extends GenericApiController /** * @NoAdminRequired * + * @param int $id File ID + * @param int[] $add Tags to add + * @param int[] $remove Tags to remove + * * Set tags for a file */ public function set(int $id, array $add, array $remove): Http\Response diff --git a/src/components/modal/EditTags.vue b/src/components/modal/EditTags.vue index 4a18943b..95860593 100644 --- a/src/components/modal/EditTags.vue +++ b/src/components/modal/EditTags.vue @@ -67,13 +67,7 @@ export default defineComponent({ }, tagFilter(element: dav.ITag, index: number) { - return ( - element.id >= 2 && - element.displayName !== '' && - element.canAssign && - element.userAssignable && - element.userVisible - ); + return element.displayName !== '' && element.canAssign && element.userAssignable && element.userVisible; }, tagLabel({ displayName }: dav.ITag) { @@ -82,7 +76,7 @@ export default defineComponent({ createOption(newDisplayName: string): dav.ITag { // do not create tags that already exist - const existing = this.getAvailable().find((x) => x.displayName === newDisplayName && this.tagFilter(x, 0)); + const existing = this.getAvailable().find((x) => x.displayName === newDisplayName); if (existing) { return existing; } diff --git a/src/services/dav/tags.ts b/src/services/dav/tags.ts index 840be7b4..3a9b61b2 100644 --- a/src/services/dav/tags.ts +++ b/src/services/dav/tags.ts @@ -38,6 +38,7 @@ export async function createTag(tag: ITag): Promise { const postData = { ...tag, name: tag.displayName, // weird + id: undefined, }; try { @@ -56,6 +57,13 @@ export async function createTag(tag: ITag): Promise { throw new Error(t('memories', 'No content-location header found')); } catch (error) { + if (error?.status === 409) { + // Tag already exists. Now this may happen e.g. if the tag isn't + // assignable or visible to the user and cause problems later. + // But that's not our problem here. + return tag; + } + throw new Error( t('memories', 'Failed to create tag {name}: {error}', { name: tag.displayName,