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

View File

@ -189,7 +189,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
key={props.position.toString()} key={props.position.toString()}
placeholder='Text' placeholder='Text'
dataField='text' dataField='text'
defaultValue={props.item ? props.item.text : ''} defaultValue={props.item?.text ?? ''}
inputStyle='tw-h-40 tw-mt-5' 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 { export interface Item {
id: string id: string
name: string name: string
text: string text?: string
data?: string data?: string
position?: Point | null position?: Point | null
date_created?: string date_created?: string