item.text is optional

This commit is contained in:
Maximilian Harz 2025-02-10 23:14:58 +01:00
parent cb727d433d
commit 2556d8c047
3 changed files with 4 additions and 4 deletions

View File

@ -172,7 +172,7 @@ export const Layer = ({
if (item.tags) {
item.text += '\n\n'
item.tags.map((tag) => {
if (!item.text.includes(`#${encodeTag(tag)}`)) {
if (!item.text?.includes(`#${encodeTag(tag)}`)) {
item.text += `#${encodeTag(tag)}`
}
return item.text
@ -180,7 +180,7 @@ export const Layer = ({
}
if (allTagsLoaded && allItemsLoaded) {
item.text.match(hashTagRegex)?.map((tag) => {
item.text?.match(hashTagRegex)?.map((tag) => {
if (
!tags.find(
(t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase(),

View File

@ -189,7 +189,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
key={props.position.toString()}
placeholder='Text'
dataField='text'
defaultValue={props.item ? props.item.text : ''}
defaultValue={props.item?.text ?? ''}
inputStyle='tw-h-40 tw-mt-5'
/>
</>

2
src/types/Item.d.ts vendored
View File

@ -18,7 +18,7 @@ interface GalleryItem {
export interface Item {
id: string
name: string
text: string
text?: string
data?: string
position?: Point | null
date_created?: string