Feed - posts #227

Merged
enes merged 23 commits from feat/131-feed-posts into staging 2025-02-14 19:54:29 +00:00
2 changed files with 35 additions and 34 deletions
Showing only changes of commit 84d5400872 - Show all commits

View File

@ -3,7 +3,12 @@ import { formatDate } from 'date-fns'
import { useDidMount, useNDKContext } from 'hooks' import { useDidMount, useNDKContext } from 'hooks'
import { useState } from 'react' import { useState } from 'react'
import { useParams, useLocation, Link } from 'react-router-dom' import { useParams, useLocation, Link } from 'react-router-dom'
import { getModPageRoute, getBlogPageRoute, getProfilePageRoute } from 'routes' import {
getModPageRoute,
getBlogPageRoute,
getProfilePageRoute,
appRoutes
} from 'routes'
import { CommentEvent, UserProfile } from 'types' import { CommentEvent, UserProfile } from 'types'
import { hexToNpub } from 'utils' import { hexToNpub } from 'utils'
import { Reactions } from './Reactions' import { Reactions } from './Reactions'
@ -20,12 +25,15 @@ export const Comment = ({ comment }: CommentProps) => {
const { ndk } = useNDKContext() const { ndk } = useNDKContext()
const isMod = location.pathname.includes('/mod/') const isMod = location.pathname.includes('/mod/')
const isBlog = location.pathname.includes('/blog/') const isBlog = location.pathname.includes('/blog/')
const isNote = location.pathname.includes('/feed')
const baseUrl = naddr const baseUrl = naddr
? isMod ? isMod
? getModPageRoute(naddr) ? getModPageRoute(naddr)
: isBlog : isBlog
? getBlogPageRoute(naddr) ? getBlogPageRoute(naddr)
: undefined : undefined
: isNote
? `${appRoutes.feed}/`
: undefined : undefined
const [commentEvents, setCommentEvents] = useState<CommentEvent[]>([]) const [commentEvents, setCommentEvents] = useState<CommentEvent[]>([])
const [profile, setProfile] = useState<UserProfile>() const [profile, setProfile] = useState<UserProfile>()
@ -121,35 +129,29 @@ export const Comment = ({ comment }: CommentProps) => {
{typeof profile?.lud16 !== 'undefined' && profile.lud16 !== '' && ( {typeof profile?.lud16 !== 'undefined' && profile.lud16 !== '' && (
<Zap {...comment.event.rawEvent()} /> <Zap {...comment.event.rawEvent()} />
)} )}
{comment.event.kind === NDKKind.GenericReply && ( <Link
<> className='IBMSMSMBSSCL_CAElement IBMSMSMBSSCL_CAEReplies'
<Link to={baseUrl + comment.event.encode()}
className='IBMSMSMBSSCL_CAElement IBMSMSMBSSCL_CAEReplies' >
to={baseUrl + comment.event.encode()} <svg
> xmlns='http://www.w3.org/2000/svg'
<svg viewBox='0 0 512 512'
xmlns='http://www.w3.org/2000/svg' width='1em'
viewBox='0 0 512 512' height='1em'
width='1em' fill='currentColor'
height='1em' className='IBMSMSMBSSCL_CAElementIcon'
fill='currentColor' >
className='IBMSMSMBSSCL_CAElementIcon' <path d='M256 32C114.6 32 .0272 125.1 .0272 240c0 49.63 21.35 94.98 56.97 130.7c-12.5 50.37-54.27 95.27-54.77 95.77c-2.25 2.25-2.875 5.734-1.5 8.734C1.979 478.2 4.75 480 8 480c66.25 0 115.1-31.76 140.6-51.39C181.2 440.9 217.6 448 256 448c141.4 0 255.1-93.13 255.1-208S397.4 32 256 32z'></path>
> </svg>
<path d='M256 32C114.6 32 .0272 125.1 .0272 240c0 49.63 21.35 94.98 56.97 130.7c-12.5 50.37-54.27 95.27-54.77 95.77c-2.25 2.25-2.875 5.734-1.5 8.734C1.979 478.2 4.75 480 8 480c66.25 0 115.1-31.76 140.6-51.39C181.2 440.9 217.6 448 256 448c141.4 0 255.1-93.13 255.1-208S397.4 32 256 32z'></path> <p className='IBMSMSMBSSCL_CAElementText'>{commentEvents.length}</p>
</svg> <p className='IBMSMSMBSSCL_CAElementText'>Replies</p>
<p className='IBMSMSMBSSCL_CAElementText'> </Link>
{commentEvents.length} <Link
</p> className='IBMSMSMBSSCL_CAElement IBMSMSMBSSCL_CAEReply'
<p className='IBMSMSMBSSCL_CAElementText'>Replies</p> to={baseUrl + comment.event.encode()}
</Link> >
<Link <p className='IBMSMSMBSSCL_CAElementText'>Reply</p>
className='IBMSMSMBSSCL_CAElement IBMSMSMBSSCL_CAEReply' </Link>
to={baseUrl + comment.event.encode()}
>
<p className='IBMSMSMBSSCL_CAElementText'>Reply</p>
</Link>
</>
)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -33,17 +33,16 @@ export const CommentsPopup = () => {
useBodyScrollDisable(true) useBodyScrollDisable(true)
const isMod = location.pathname.includes('/mod/') const isMod = location.pathname.includes('/mod/')
const isBlog = location.pathname.includes('/blog/') const isBlog = location.pathname.includes('/blog/')
const isNote = location.pathname.includes('/feed/') const isNote = location.pathname.includes('/feed')
const baseUrl = naddr const baseUrl = naddr
? isMod ? isMod
? getModPageRoute(naddr) ? getModPageRoute(naddr)
: isBlog : isBlog
? getBlogPageRoute(naddr) ? getBlogPageRoute(naddr)
: isNote
? appRoutes.feed
: undefined : undefined
: isNote
? `${appRoutes.feed}/`
: undefined : undefined
const { event } = useLoaderData() as CommentsLoaderResult const { event } = useLoaderData() as CommentsLoaderResult
const { const {
size, size,