feat: improve notification content
This commit is contained in:
@@ -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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user