Files
standardnotes-app-web/app/assets/javascripts/Components/ContentListView/ContentListItem.tsx
2022-05-30 12:42:52 +05:30

39 lines
1.0 KiB
TypeScript

import { ContentType, SNTag } from '@standardnotes/snjs'
import { FunctionComponent } from 'react'
import FileListItem from './FileListItem'
import NoteListItem from './NoteListItem'
import { AbstractListItemProps } from './Types/AbstractListItemProps'
const ContentListItem: FunctionComponent<AbstractListItemProps> = (props) => {
const getTags = () => {
if (props.hideTags) {
return []
}
const selectedTag = props.appState.tags.selected
if (!selectedTag) {
return []
}
const tags = props.appState.getItemTags(props.item)
const isNavigatingOnlyTag = selectedTag instanceof SNTag && tags.length === 1
if (isNavigatingOnlyTag) {
return []
}
return tags.map((tag) => tag.title).sort()
}
switch (props.item.content_type) {
case ContentType.Note:
return <NoteListItem tags={getTags()} {...props} />
case ContentType.File:
return <FileListItem tags={getTags()} {...props} />
default:
return null
}
}
export default ContentListItem