fix tag issue

This commit is contained in:
Anton Tranelis 2024-02-02 19:50:53 +01:00
parent a0dcf4f193
commit 994ea884a2
3 changed files with 3 additions and 3 deletions

View File

@ -159,7 +159,7 @@ export const Layer = ({
if (allTagsLoaded && allItemsLoaded) {
item[itemTextField].toLocaleLowerCase().match(hashTagRegex)?.map(tag => {
if ((!tags.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) && !newTagsToAdd.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) {
const newTag = { name: tag.slice(1).toLocaleLowerCase(), color: randomColor() };
const newTag = { id: crypto.randomUUID(), name: tag.slice(1).toLocaleLowerCase(), color: randomColor() };
setNewTagsToAdd(current => [...current, newTag]);
}
});

View File

@ -1,7 +1,7 @@
import * as React from 'react'
import { useEffect } from 'react';
import { ItemsApi, Tag } from '../../types';
import { useAddTag, useSetTagData, useSetTagApi } from './hooks/useTags'
import { useSetTagData, useSetTagApi } from './hooks/useTags'
export function Tags({data, api} : {data?: Tag[], api?: ItemsApi<Tag>}) {
const setTagData = useSetTagData();

View File

@ -69,7 +69,7 @@ export class Geometry {
export interface Tag {
color: string;
id?: string;
id: string;
name: string;
}