tags: remove some filters

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/877/head
Varun Patil 2023-10-14 14:35:47 -07:00
parent d73d96ed27
commit c8c6f1f8a1
3 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -38,6 +38,7 @@ export async function createTag(tag: ITag): Promise<ITag> {
const postData = {
...tag,
name: tag.displayName, // weird
id: undefined,
};
try {
@ -56,6 +57,13 @@ export async function createTag(tag: ITag): Promise<ITag> {
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,