feat: improve notification content
This commit is contained in:
parent
9f0f39f480
commit
be7712948a
4 changed files with 31 additions and 3 deletions
|
|
@ -13,6 +13,8 @@ import { useTranslation } from 'react-i18next'
|
|||
import PullToRefresh from 'react-simple-pull-to-refresh'
|
||||
import { FormattedTimestamp } from '../FormattedTimestamp'
|
||||
import UserAvatar from '../UserAvatar'
|
||||
import { embedded, embeddedNostrNpubRenderer, embeddedNostrProfileRenderer } from '../Embedded'
|
||||
import { extractEmbeddedNotesFromContent, extractImagesFromContent } from '@/lib/event'
|
||||
|
||||
const LIMIT = 100
|
||||
|
||||
|
|
@ -268,7 +270,17 @@ function CommentNotification({ notification }: { notification: Event }) {
|
|||
}
|
||||
|
||||
function ContentPreview({ event }: { event?: Event }) {
|
||||
const { t } = useTranslation()
|
||||
const content = useMemo(() => {
|
||||
if (!event) return null
|
||||
const { contentWithoutEmbeddedNotes } = extractEmbeddedNotesFromContent(event.content)
|
||||
const { contentWithoutImages, images } = extractImagesFromContent(contentWithoutEmbeddedNotes)
|
||||
return embedded(contentWithoutImages + (images?.length ? `[${t('image')}]` : ''), [
|
||||
embeddedNostrProfileRenderer,
|
||||
embeddedNostrNpubRenderer
|
||||
])
|
||||
}, [event])
|
||||
if (!event) return null
|
||||
|
||||
return <div className="truncate flex-1 w-0">{event.content}</div>
|
||||
return <div className="truncate flex-1 w-0">{content}</div>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue